I have implemented cookiesdirective.js which can be found here cookiesdirective.com and Statcounter code is not working. I am using the following code (DoYourOwnSite, standard):
var sc_project=9181072;
var sc_invisible=1;
var sc_security="328a83d2";
var scJsHost = (("https:" == document.location.protocol) ? "https://secure." : "http://www.");
document.write("<sc"+"ript type='text/javascript' src='" + scJsHost + "statcounter.com/counter/counter.js'></"+"script>");
Since cookiesdirective.js requires to remove the tags, I have removed them, but it is still not working. On the other hand, Google Analytics code is working without a problem. I am sure it is about changing the code a bit so it will work inside another javascript, but I do not now how to do it.
Thanks,
Goran
Solved. I had to change the statcounter code a bit:
var sc_project=xxxxxxxxxx;
var sc_invisible=1;
var sc_security="xxxxxxxxxxx";
var imported = document.createElement('script');
imported.type = 'text/javascript';
imported.async = true;
var scJsHost = (("https:" == document.location.protocol) ? "https://secure." : "http://www.");
imported.src = scJsHost + "statcounter.com/counter/counter_xhtml.js";
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(imported, s);
Thanks anyway.
Related
Wanted to achieve google custom search result like below
expected result (without any popup):
But i'm getting result something like below one
Observe the above result is not pre-populated and does not give resume tags like Indeed,LinkedIn
When i search for software developer resume then it will give me result like below one
Question: please help me to get pre-populated result like 1st image without any popup
Here is what i have tried:
(function() {
var cx = '005502706694827175734:jh1_mjmyukc';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
'//www.google.com/cse/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();
<gcse:search linktarget="_parent" resultsUrl="https://cse.google.com/cse/home?cx=008650345519931166596:ni_z2d9ca00#gsc.tab=0&gsc.sort=&gsc.ref=more%3Alinkedin"></gcse:search>
// this url gives Indeed,LinkedIn related results https://cse.google.com/cse/home?cx=008650345519931166596:ni_z2d9ca00#gsc.tab=0&gsc.sort=&gsc.ref=more%3Alinkedin
Try using the "two page" layout as described on these pages:
https://support.google.com/customsearch/answer/2633315
https://developers.google.com/custom-search/docs/tutorial/implementingsearchbox
In my webscraper some of the content is coming with advertisements and some java script functions in it. Like the below;
(function() { var infAds = document.createElement('script'); infAds.async = true; infAds.type = 'text/javascript'; var useSSL = 'https:' == document.location.protocol; infAds.src = (useSSL ? 'https:' : 'http:') + '//d.infeed.id/widget-50716010/loader/all/'; var node = document.getElementById('cont-50716010-all'); node.parentNode.insertBefore(infAds, node); })();
I have used lxml.html.clean.Cleaner to remove the scripts and styles from the content. But it is not all removing what i expected. I tried like the below;
from lxml.html.clean import Cleaner
cleaner = Cleaner()
cleaner.javascript = True
cleaner.scripts = True
content = "Page content"
clean_content = cleaner.clean_html(content)
print(clean_content)
But if i use
__clean_content = lxml.html.toString(cleaner.clean_html(content))
__
i am getting the below type error;
TypeError: Type 'str' cannot be serialized.
Using regex also i have tried, it wasn't worked out too. Any suggestions or help would be greatly appreciable!
Thanks in advance.
I have an AngularJS webapp where there are no separate pages.
I have set up a goal completion so that there's a code that is triggered by a javascript event,
and it has the following structure:
function call_completion(){
window.google_conversion_id = 973404965;
window.google_conversion_language = "en";
window.google_conversion_format = "1";
window.google_conversion_color = "ffffff";
window.google_conversion_label = "doGHCLPK2wkQpfaT0AM";
window.google_conversion_value = 1.000000;
window.google_remarketing_only = false;
var s = document.createElement('script');
s.type = "text/javascript";
s.src = '//www.googleadservices.com/pagead/conversion.js';
document.body.appendChild(s);
}
Yet, I can't see any completions registered in Google Analytics. What could be the problem?
Is this the correct way to do it? Is there perhaps some nifty plugin that gets this problem right?
UPDATE:
For the new Universal Analytics, there is a plugin called angular-ga.
It eliminates the whole question.
You shouldn't append the script to your view, since it won't be executed.
You should use this:
$.getScript( "http://www.googleadservices.com/pagead/conversion.js" );
To get the script working on that page and execute it.
Hope this helps :)
The <noscript> part also has to be included.
Something like this:
$('body')
.append('\
<!-- Google Code for Subscriptions Conversion Page -->\n\
<script type="text/javascript">\n\
/* <![CDATA[ */\n\
var google_conversion_id = 973404965;\n\
var google_conversion_language = "en";\n\
var google_conversion_format = "1";\n\
var google_conversion_color = "ffffff";\n\
var google_conversion_label = "doGHCLPK2wkQpfaT0AM";\n\
var google_conversion_value = 1.000000;\n\
var google_remarketing_only = false;\n\
/* ]]> */\n\
</script>\
');
$('body')
.append('<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">')
.append($('<noscript>')
.append($('<div style="display:inline;">')
.append('<img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/973404965/?value=1.000000&label=doGHCLPK2wkQpfaT0AM&guid=ON&script=0"/>')
)
);
Setting up Google Custom Search: https://www.google.com/cse/
I would like to be able to use JS to call the search terms the users are keying.
<script>
(function () {
var cx = 'mygoogle-gcse-id';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
'//www.google.com/cse/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();</script>
How do I use JS to call the elements entered into the search form?
I would want to call:
onblur="somefunction('gsce-input-data')";
The search elements are created on the fly when the code above loads the script. This means you need to attach your listeners using the "live" method, so that they get attached when the element actually enters the DOM:
$('.gsc-input').live('blur', function(e) { //do something });
Here is the fiddle example: http://jsfiddle.net/pASWm/1/
How can i convert this HTML code into Action script code, i am an android and actionscript developer, i dont know much about HTML and java script. i have tried different forums, i know it can be converted, can someone help me
<script type="text/javascript">
adroll_adv_id = "JD5ZGBNO4RBYVAMMMPX3J7";
adroll_pix_id = "CEJOJM5N5VAHBKCVMT2DML";
(function () {
var oldonload = window.onload;
window.onload = function(){
__adroll_loaded=true;
var scr = document.createElement("script");
var host = (("https:" == document.location.protocol) ? "https://s.adroll.com" : "http://a.adroll.com");
scr.setAttribute('async', 'true');
scr.type = "text/javascript";
scr.src = host + "/j/roundtrip.js";
((document.getElementsByTagName('head') || [null])[0] ||
document.getElementsByTagName('script')[0].parentNode).appendChild(scr);
if(oldonload){oldonload()}};
}());
</script>
Well the code you listed is actually javascript encased in a html tag. Javascript and actionscript are pretty similar, you should be able to use the same code with minimal changes. Just use the javascript as a reference to code it with actionscript