Subscribe now and choose from over 30 free gifts worth up to £49 - Plus get £25 to spend in our shop
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 🙂
Are you using a framework like jQuery? If sotry wrapping it in $(document).ready({code to run});
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....
Hit F12, go to script tag, click Start Debugging. Refresh page, see if there are any script errors.
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!
Any poss that there's a security setting on your IE8 stopping javascript being executed in externally loaded files from spawned tabs?
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]
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.
... or run a server locally - XAMPP is great, and Visual Studio 2010 has one built in...
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 😉
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?
Want to post it somewhere we can see it? Try building in [url= http://jsfiddle.net/ ]http://jsfiddle.net/[/url] and posting a link.
@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.
Can you put up your code (or just the offending bits) on pastebin or something?
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!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Don't you only need the ending forward slash when it's a single tag? Like [code]< br / >[/code]
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>
Ah yes, [code]<img .... />[/code] was another.
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.
However, confusingly in HTML5 - you can use either... 🙄
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.
once again ! thankyou!
