Khalid Taoufik

Navigation

Skip navigation.

Search

Site navigation

Email conversation

FromKhalid Taoufik
ToMe
SubjectScript tag compatibility problem with MAC Os
Date10 January 2005 18:43
Hi,
 
First i would like to thank you for your great and very helpful web site, great 
JOB ;)
 
i'm having aproblem with a javascript code wich run correctly with IE and 
Netscape on PC. the same script run also correctly with Netscap on MAC.
 
My proble is that this script does not run with IE and safari on MAC OS
 
the script consists to create dynamicly (using javascript and DHTML) a SCRIPT 
Element and specify the SRC attribute of the Element to a given .aspx(ASP.NET 
page) page  (this page generate dynamicly a javascript code and which will be 
excuted on the page where the script Element is created). the .aspx page does 
not have the same domain name as the page containing the SCRIPT Element.
 
here is the code:
 
var ReturnVal1 = "";
var ReturnVal2 = "";
var ReturnVal3 = "";
 
function getDynamicScript(Variable)
{
var buffer;
 
buffer=document.createElement('SCRIPT');

buffer.setAttribute('src','http://www.otherDomainname.com/CustFrontEnd/cstremoteServer.aspx?VID=<http://www.otherDomainname.com/CustFrontEnd/cstremoteServer.aspx?VID>'+ Variable);

document.body.appendChild(buffer);
 
}
 
the cstremoteServer.aspx page which is the src attribute of the created SCRIPT 
Element, returns some thing like
 
 
ReturnVal1 = "value1";
ReturnVal2 = "value2";
ReturnVal3 = "value3";
 
 
is there some thing i'm making wrong, or is there some special things that o 
should use when the browser is IE or safari and the OS is MAC?
 
Regards.
 
Khalid TAOUFIK
FromMe
ToKhalid Taoufik
SubjectRe: Script tag compatibility problem with MAC Os
Date10 January 2005 21:50
Khalid,

> i'm having aproblem with a javascript code wich run correctly with IE and
> Netscape on PC. the same script run also correctly with Netscap on MAC.
> My proble is that this script does not run with IE and safari on MAC OS

Note, the script will also work correctly in Opera 7.5+ on windows/linux/mac
- please do not ignore this browser (this is the browser I use myself, and
it is one of the most capable browsers available). You can download it and
use it for free - http://www.opera.com/download/

> the script consists to create dynamicly (using javascript and DHTML) a
> SCRIPT Element and specify the SRC attribute of the Element to a given

And here is your problem. You are asking too much of these browsers. They
are simply not capable of loading a new script file after the page has
loaded. They will correctly insert the element, but the script file simply
will not load.

What you _can_ do is to use an iframe, and load a HTML page into that
iframe, where the new page contains:
<script type="text/javascript"><!--
parent.ReturnVal1 = "value1";
parent.ReturnVal2 = "value2";
parent.ReturnVal3 = "value3";
//--></script>

I have documented this technique on
http://www.howtocreate.co.uk/loadingExternalData.html

Of course, at this moment, you will run into cross domain scripting
problems. (XML importing could also be used, but then you would run into
the same problem.) The solution is to use a script (asp/php/jsp/perl)
running on your own server that reads this external script address, and
serves it as if it were its own. Then your script can load this instead.

This will work in virtually all browsers, and is the best way to do this.

Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
This site was created by Mark "Tarquin" Wilton-Jones.
Don't click this link unless you want to be banned from our site.