dflow Posted February 1, 2015 Share Posted February 1, 2015 This code works: How can I execute this in one script tag? <script> var urlParams; (window.onpopstate = function () { var match, pl = /\+/g, // Regex for replacing addition symbol with a space search = /([^&=]+)=?([^&]*)/g, decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); }, query = window.location.search.substring(1); urlParams = {}; while (match = search.exec(query)) urlParams[decode(match[1])] = decode(match[2]); })(); var a = urlParams["a"]; var b = urlParams["b"]; // var url = "http://example.com/tracker/"+ a +'/' + b; var iDiv = document.createElement('img'); iDiv.id = '5050'; iDiv.src = +url; iDiv.width = '14'; iDiv.height = '14'; document.getElementsByTagName('body')[0].appendChild(iDiv); iDiv.appendChild(innerDiv); </script> <script> document.getElementById("5050").src ="http://example.com/tracker/"+ a +'/' + b; </script> Link to comment https://forums.phpfreaks.com/topic/294301-how-to-get-it-into-one-script-tag/ Share on other sites More sharing options...
requinix Posted February 1, 2015 Share Posted February 1, 2015 Well, you could, you know, remove the </script> <script>Or am I missing something? Link to comment https://forums.phpfreaks.com/topic/294301-how-to-get-it-into-one-script-tag/#findComment-1504501 Share on other sites More sharing options...
dflow Posted February 1, 2015 Author Share Posted February 1, 2015 Well, you could, you know, remove the </script> <script>Or am I missing something? obviously I did, but then: document.getElementById("5050").src ="http://example.com/tracker/"+ a +'/' + b; isn't executed for some reason Link to comment https://forums.phpfreaks.com/topic/294301-how-to-get-it-into-one-script-tag/#findComment-1504503 Share on other sites More sharing options...
dflow Posted February 1, 2015 Author Share Posted February 1, 2015 iDiv.appendChild(innerDiv); was causing the error Link to comment https://forums.phpfreaks.com/topic/294301-how-to-get-it-into-one-script-tag/#findComment-1504512 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.