Viewing 22 posts - 1 through 22 (of 22 total)
  • IE8 and AJAX loading HTML pages with Javascript in them?
  • roady_tony
    Free Member

    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 🙂

    nixie
    Full Member

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

    roady_tony
    Free Member

    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….

    retro83
    Free Member

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

    xiphon
    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!

    IanMunro
    Free Member

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

    jeff
    Full Member

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

    Sounds like you’ve hit this issue : Same Origin Policy

    patricksingletrack
    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.

    xiphon
    Free Member

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

    roady_tony
    Free Member

    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 😉

    nixie
    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?

    patricksingletrack
    Free Member

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

    roady_tony
    Free Member

    @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.

    chvck
    Free Member

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

    roady_tony
    Free Member

    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!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    xiphon
    Free Member

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

    prezet
    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>

    xiphon
    Free Member

    Ah yes, <img .... /> was another.

    prezet
    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.

    prezet
    Free Member

    However, confusingly in HTML5 – you can use either… 🙄

    patricksingletrack
    Free Member

    Validate http://validator.w3.org/ or use a FF plugin such as HTML Validator to keep an eye as you go along. Obviously no good for HTML5 though.

    roady_tony
    Free Member

    once again ! thankyou!

Viewing 22 posts - 1 through 22 (of 22 total)

The topic ‘IE8 and AJAX loading HTML pages with Javascript in them?’ is closed to new replies.