[web] [JavaScript] IE Does Not Like Online Script References
I'm writing a CYOA game using javascript and HTML. I use three files:
- game.htm, the actual page where the game is played, referring to Shade.js
- Shade.js, the "engine" for the game, referring to gf.js (by dynamically adding a script object to the page)
- gf.js, a collection of generic functions
I have two versions of each, one on my computer and one on either of two websites. game.htm and Shade.js reside on one website while gf.js resides on another.
My problem is this:
Internet Explorer has an "Object expected" error when I view game.htm, most likely from that for some reason it doesn't get to one of the scripts. The same page viewed in Firefox works perfectly. This happens whether game.htm is local or online, but when referring to the online files.
My question is this:
What setting in IE, if one exists, can I change so that IE will get to the files?
Edit: Just to be clear, this is IE7.
[Edited by - Tallun on December 23, 2007 6:27:14 PM]
As I understand it, you have game.htm and Shade.js on one domain and gf.js on another domain? Well then, your problem is actually a feature! You're attempting something called "Cross-Site Scripting" which is specifically disabled as a security threat. It's a shame that FireFox isn't doing the same, actually.
It's possible I should have been more specific and said "subsites"; does this same thing apply to subsites?
Furthermore, does this apply to local files referencing online files as well?
But that information is a good lead, and might possibly solve my problem. I'll try it and let you know.
Thanks!
Edit:
I moved everything to the same directory on the one subsite and changed the references to just the names of the files and not their directories. Unfortunately the same problem still exists.
Perhaps I completely overlooked the potential of this bit of code in Shade.js to be a problem:
That seems to have worked before, but now I think it might have something to do with it.
[Edited by - Tallun on December 26, 2007 1:36:55 PM]
Furthermore, does this apply to local files referencing online files as well?
But that information is a good lead, and might possibly solve my problem. I'll try it and let you know.
Thanks!
Edit:
I moved everything to the same directory on the one subsite and changed the references to just the names of the files and not their directories. Unfortunately the same problem still exists.
Perhaps I completely overlooked the potential of this bit of code in Shade.js to be a problem:
{ var x = document.createElement("script"); x.src = "gf.js"; document.getElementsByTagName("head")[0].appendChild(x);}
That seems to have worked before, but now I think it might have something to do with it.
[Edited by - Tallun on December 26, 2007 1:36:55 PM]
your script loading way is realy diiferen i was find another way .
anyway using body is more stable then head.
i wish to see scripts can load at runtime on c++ too.
anyway using body is more stable then head.
i wish to see scripts can load at runtime on c++ too.
What method would you suggest?
You're suggesting that I should append the tag to the body instead? I'll try that.
Edit: It didn't seem to make a difference. I'd like to try your method, what is it?
You're suggesting that I should append the tag to the body instead? I'll try that.
Edit: It didn't seem to make a difference. I'd like to try your method, what is it?
I seem to have found a (possibly temporary) solution, though less satisfactory than it might have been. The problem was indeed with including gf.js, as moving it to game.htm has made it work. I was really looking for a way for it to automatically be included with Shade.js, but without another solution it'll have to do for now.
If you have any other ideas, please let me know.
Thanks!
If you have any other ideas, please let me know.
Thanks!
on my way im using scripts from text referances.
using location object. you can execute scripts on ie.
just disadventage is it needs alret prompt stuffs at end of script.
just add "javascipr:" to start of script. and alert at end it wil use it as a script referance.
if it says object is undefined your script is probally owerwriten or not executed.
using location object. you can execute scripts on ie.
just disadventage is it needs alret prompt stuffs at end of script.
just add "javascipr:" to start of script. and alert at end it wil use it as a script referance.
if it says object is undefined your script is probally owerwriten or not executed.
use this way instead of x.src = "gf.js";
command_string='function hw(){alert(hello world)};'
x.text=command_string;
so in example hw() will defined on local area and it will be accesible.
and allmost any wariable/function defined or pointed here will be accessible .
[Edited by - RSC_x on December 30, 2007 2:22:40 PM]
command_string='function hw(){alert(hello world)};'
x.text=command_string;
so in example hw() will defined on local area and it will be accesible.
and allmost any wariable/function defined or pointed here will be accessible .
[Edited by - RSC_x on December 30, 2007 2:22:40 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement