I have this code to prevent executing on page ucp.php?mode=register, but i want it to work on other pages. With this code its not working (not executing on all webpages).:
<script>
if ( window.location.toString().match(/[/ucp.php\?mode=register]/)){
var fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript")
fileref.setAttribute("src","//sk.search.etargetnet.com/generic/uni.php?g=5:500")
fileref.setAttribute("async","true")
fileref.setAttribute("data-ad-type","iframe v2.0")
fileref.setAttribute("charset","utf-8")
}
</script>
How to prevent exectugin this JS:
<script type="text/javascript" async="true" data-ad-type="iframe v2.0" charset="utf-8" src="//sk.search.etargetnet.com/generic/uni.php?g=5:500"></script>
on page ucp.php?mode=register
Thats the question.
window.location.toString().match(/[/ucp.php\?mode=register]/)is matching the current page URL and looking for a pattern of[/ucp.php\?mode=register]. You'll need to alter this pattern, or simply remove this condition, and only place this code on pages where you want it to be executed. If you'd like to alter the pattern, do some research on RegEx.window.locationinstead of regex?window.location.pathnamewill give you the page,window.location.searchwill give you the query string.