I have a block of JS code on site footer that I need to remove for a particular page using jQuery. Any help guys ?
Thanks a lot for your time.
Best regards.
<script language="javascript" type="text/javascript"><!--
si_transact_label='My-label';
si_transact_id=123456;
si_transaction_amount='0';
var now= new Date();
//--></script>
<script language="javascript" type="text/javascript">
document.write('<s'+'cript language="javascript" type="text/javascript" src="'+document.location.protocol+'//dms.netmng.com/si/CM/Tracking/TransactionTracking.aspx?siclientid=7244' + '&TransactionAmount=' + si_transaction_amount + '&SICustTransType=' + si_transact_id + '&timecode=' + now.getTime() + '&jscript=1"></s'+'cript>');
The code you’ve provided just sets a group of variables; it doesn’t actually do anything. Presumably those variables are used elsewhere?
You can’t just “remove the code” using jQuery — by the time jQuery is available on the page, this code will also have been loaded and run, and these variables will be populated. Removing the code after it’s run won’t do anything because it’s already done it’s thing.
Depending what they’re used for, you could try unsetting the variables — something like this:
but if they’ve been used for their main purpose already, then again, removing them won’t make any difference.
More likely, what you need to do is not include them in the page in the first place. This would be done in your back end code – ie PHP? ASP.net? or whatever you’re using, but not in the front-end jQuery code.