Question

Sorry about another jquery .load() with IE8 question. I've done two days of searching and testing and I'm stumped. Basically I have a simple php page that gets an external site: quality.php

<?php
    $url = 'http://www.v2cigs.com/pages/how-v2-works.html';
    $htm = file_get_contents($url);
    echo $htm;
?>

Then in a separate file, I load this page and replace a couple of lines that are not relevant to me:

<div id="v2info"></div>
<script>
$(function(){
    $( "#v2info" ).load( "test/quality.php #page_content", function() {
        $(this).html($(this).html().replace("Starter Kit Savings Chart", "<!--Starter Kit Savings Chart"));
        $(this).html($(this).html().replace("How V2 Works", ""));
    }); 
});
</script>

This loads perfectly in all browsers if I put it into a page all on it's own. My issue is when I add it to my standard Opencart site, something about the replace lines is breaking in IE8 only. Without the replace lines, it will load the page in IE8. It works on IE10, Chrome, Safari and Firefox. I'm gueesing IE8 doesn't like one of my javascript files as part of the Opencart theme, or there's something wrong with my script.

I have no idea about javascript at the moment, so I'm having a lot of trouble trying to troubleshoot it. This is actually my first go and I'm at a loss. The full page is at http://www.vapourcigs.com.au. Click on "Everything You Need To Know" then "How V2 Works". The direct link is http://www.vapourcigs.com.au/information/how-v2-works

Was it helpful?

Solution

Wow, I just figured it out. It's because I'm replacing a string with a html comment "

I simply replaced this line:

$(this).html($(this).html().replace("Starter Kit Savings Chart", "<!--Starter Kit Savings Chart"));

with:

$(this).html($(this).html().replace("Starter Kit Savings Chart", "\<\!\-\-Starter Kit Savings Chart"));

Works perfectly!

I would still appreciate comments if I helped you out or if you can improve my script. As I mentioned earlier, it's my first crack at jquery so always happy to improve.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top