2

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>');

1
  • Try and remove JavaScript bro..... just... try... it.. Commented Sep 14, 2012 at 15:16

1 Answer 1

2

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:

si_transact_label=null;
si_transact_id=null;
si_transaction_amount=null;
var now= null;

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.

Sign up to request clarification or add additional context in comments.

4 Comments

well, thanks for your reply first of all SDC. It's .net, but I don't have access to the server side coding and hence looking for a client side solution. The variables are getting used by some tracking code by a third party software, if I am to give more details. And not including the variables is not a solution neither since it's getting called from a common footer kind of thing. Also, removing it using jQuery once it's been executed looks a funny solution as it won't serve really anything. isn't there a way to get rid of it before it gets executed ?
exactly my point -- removing it after it's been executed is pointless, just as you say. But it will get executed before jQuery is loaded, which means that a jQuery solution is impossible.
hmmm ... so I'm in some sort of a black hole here ... thanks SDC.
yep, that's pretty much what I'm saying. Sorry to be the bearer of bad news.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.