Dynamic activation of Google AdWords conversion tracking explodes in safari

I am working on a one-page application that probably runs more than 1 conversion per page.

I need to run the google conversion snippet, so I assumed that I could run it at runtime. The snippet looks something like this:

<script type="text/javascript">
        /* <![CDATA[ */
        var google_conversion_id = XXXXXXXX;
        var google_conversion_language = "en";
        var google_conversion_format = "2";
        var google_conversion_color = "ffffff";
        var google_conversion_label = "XXXXXXXXXXXXXXX";
        var google_conversion_value = 25.00;
        /* ]]> */
        </script>
<script type="text/javascript" src="http://www.googleadservices.com/pagead/conversion.js">
        </script>

I use javascript to insert a fragment when starting a conversion. I do it like this:

function(id,url,content){
        // add script
        var script   = document.createElement("script");
        script.type  = "text/javascript";
        if(url) script.src   = url;
        if(content) script.text = content;
        var bucket = document.getElementById(id);
        bucket.appendChild(script);

        debugger;

    }

This works in all browsers in which I tried it except safari.

In safari, when a second script tag is added, the contents of the entire body tag are replaced by google's iFrame. Actually the whole house. The contents of the head are also destroyed.

What the hell is going on in this google script, and how can I paste this without any explosion ?!

Update:

, - , script. , bucket.innerHTML = '' debugger, Safari. , FF 3.6 , , DOM.

, , AdWords - , .

htaccess , , iFrame. .

+3
1

, Google iFrame?

, :

<iframe src="/documents/adsense.htm" width="728px" height="90px" frameborder="0" marginwidth ="0px" marginheight="0px" scrolling="no"></iframe>

iFrame :

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Google Adsense</title>
<base target="_parent">
</head>
<body>
<!--insert Google Adsense Code Here-->
</body>
</html>

Google - .

+3

All Articles