IE8 and AJAX loadin...
 

Subscribe now and choose from over 30 free gifts worth up to £49 - Plus get £25 to spend in our shop

[Closed] IE8 and AJAX loading HTML pages with Javascript in them?

21 Posts
9 Users
0 Reactions
100 Views
Posts: 0
Free Member
Topic starter
 

sorry for the confusing subject headings....
basically new to this web programming stuff and have encountered a wierdy thing
in chrome and firefox i have running perfectly using javascript a tabbed base website that loads the content of the tabs upon clicking them from external HTML files. in some of these files i have some javascript like
<script type = "text/javascript">
...javasript stuff
</script>

all work fine except in IE8 !!!!!!!!!!

does IE8 just now allow this?
does IE9 and above?

i've also tried adding in the //<!CDATA stuff too
i've heard on the web that some older browsers you need to 'comment out' the java script? should i really code that or is it a given that older browsers are not supported?

thanks web developer peeps, sorry to divert you from reading about bike pron 🙂


 
Posted : 13/02/2012 8:08 pm
Posts: 8019
Full Member
 

Are you using a framework like jQuery? If sotry wrapping it in $(document).ready({code to run});


 
Posted : 13/02/2012 8:58 pm
Posts: 0
Free Member
Topic starter
 

yes jquery, but thats the point, when i run it in chrome/fox the external html files that hold the <script... javascript .. /script> commands execute when the external file is loaded, which is fine. IE8 just will not load the file at all - so there is some display text above the javascript which fails to load in IE8 and the javascript itself, chrome/fox works fine. if i REMOVE the <script> stuff, IE8 loads the file and displays the text....


 
Posted : 14/02/2012 9:03 am
Posts: 621
Free Member
 

Hit F12, go to script tag, click Start Debugging. Refresh page, see if there are any script errors.


 
Posted : 14/02/2012 9:06 am
Posts: 0
Free Member
 

You have just discovered what separates 'designers' from 'developers' - cross-browser compatibility debugging. It's probably the most time consuming part of building websites...

Good luck!


 
Posted : 14/02/2012 9:07 am
Posts: 0
Free Member
 

Any poss that there's a security setting on your IE8 stopping javascript being executed in externally loaded files from spawned tabs?


 
Posted : 14/02/2012 9:11 am
 jeff
Posts: 227
Free Member
 

nab remote HTML, stash locally, update refs. see if it works.

Sounds like you've hit this issue : [url= http://en.wikipedia.org/wiki/Same_origin_policy ]Same Origin Policy[/url]


 
Posted : 14/02/2012 9:57 am
Posts: 0
Free Member
 

Yes, always build on a real server of you will spend ages trying to fix non-existent problems. I leant that one the hard way.


 
Posted : 14/02/2012 10:26 am
Posts: 0
Free Member
 

... or run a server locally - XAMPP is great, and Visual Studio 2010 has one built in...


 
Posted : 14/02/2012 10:59 am
Posts: 0
Free Member
Topic starter
 

thanks for the advice everyone!
have tried going though the security settings on IE8, am running XAMPP and IE8 settings are set to INTRANET and LOW and checked all scripting settings to enabled as required...
I'd already gone through DEBUG, it doesnt tell me much because i'm loading the .HTML (with the javascript inside it) dynamically. it reports NO errors

I've yet to see a working example on the internet, the only one i've found is using <iframe> .

if i remove the javascript, the .html loads with no problems. i add it, it just doesnt load.
it all works in chrome/fox , also with no errors.

i'll keep hunting around.

if anyone could prove this is working for them, that would be fekin awesome 😉


 
Posted : 16/02/2012 10:15 am
Posts: 8019
Full Member
 

How are you loading the tabs (script example)? I quite commonly load stuff via ajax using jquery with inline script tags that work in IE8. The script executes when added to the dom.

Are the external files full html docs, or just partial html?


 
Posted : 16/02/2012 10:21 am
Posts: 0
Free Member
 

Want to post it somewhere we can see it? Try building in [url= http://jsfiddle.net/ ]http://jsfiddle.net/[/url] and posting a link.


 
Posted : 16/02/2012 2:29 pm
Posts: 0
Free Member
Topic starter
 

@nixie - html externals contain html and javascript code wrapped in <script /script> tags as per normal.
and i am doing the same as you , building the tabs dynamically in JQuery, loading the content (the external html/jscript) when clicked.
if i include jscript in the external html, IE8 wont load it at all, the other browers do & execute the jscript inside the <script /script> tags.

@patrick- cant really do that as it complex to load external files using jsfiddle.


 
Posted : 16/02/2012 2:42 pm
Posts: 349
Free Member
 

Can you put up your code (or just the offending bits) on pastebin or something?


 
Posted : 16/02/2012 2:44 pm
Posts: 0
Free Member
Topic starter
 

Hey everyone - i found the issue with my external html, it was coding error, i had a div like this

<div id = "my_div" />
...
html stuff
...
<script........>
javascript stuff
alert("ran script!");
</script>

</div>

the extra / at the top line stopped the SCRIPT section from working in IE8 and previous versions, but working in all others.
when i removed the script, the load worked fine
when i removed the extra '/' and put back the script it worked in IE8 (and previous)

crikey thats 2 days of looking!!!!!!!!!

thanks to you all!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


 
Posted : 16/02/2012 3:55 pm
Posts: 0
Free Member
 

Don't you only need the ending forward slash when it's a single tag? Like [code]< br / >[/code]


 
Posted : 16/02/2012 3:58 pm
Posts: 2086
Free Member
 

Just to clarify, so you know what that '/' does... that indicates that element is a singleton, of which a 'div' element is not. 'div's must always contain an open and close tag like so: <div></div>

There are some elements in HTML that are singletons like 'img', and 'link' etc:

<img src="" alt="" />
<div>...</div>


 
Posted : 16/02/2012 4:00 pm
Posts: 0
Free Member
 

Ah yes, [code]<img .... />[/code] was another.


 
Posted : 16/02/2012 4:02 pm
Posts: 2086
Free Member
 

Don't you only need the ending forward slash when it's a single tag?

Only in XHTML, it's not valid in HTML - so check the doctype you're using.


 
Posted : 16/02/2012 4:11 pm
Posts: 2086
Free Member
 

However, confusingly in HTML5 - you can use either... 🙄


 
Posted : 16/02/2012 4:11 pm
Posts: 0
Free Member
 

Validate [url= http://validator.w3.org/ ]http://validator.w3.org/[/url] or use a FF plugin such as [url= http://users.skynet.be/mgueury/mozilla/ ]HTML Validator[/url] to keep an eye as you go along. Obviously no good for HTML5 though.


 
Posted : 16/02/2012 4:17 pm
Posts: 0
Free Member
Topic starter
 

once again ! thankyou!


 
Posted : 16/02/2012 5:14 pm