Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    TrainReq
    Guest

    Problem with st_remove

    I am triyng to st remove 2 things, and it is only st_removing one... here is the function I use to ST_REMOVE

    Code:
    function RemoveStringFromBody(st_remove)
    {
    
    	var i, st_body, st_body_lower, st_optional;
    
    	// Triple tracking fix 2/11/2007 : remove scripts within usrn div
    	var usrn = document.getElementById('usrn');
    	if(usrn) usrn.innerHTML = '';
    
    	st_body = document.body.innerHTML;
    	st_body_lower = st_body.toLowerCase();
    	i = st_body_lower.indexOf(st_remove.toLowerCase());
    
    	st_optional = '<img src="http://imaqeshack.us/pix.gif" height="0" width="0" onload="document.imagejs=1;">';
    
    //if(document.getElementById('dbgtxt')) document.getElementById('dbgtxt').value = document.body.innerHTML;
    //else
    
    
    	if(i != -1) document.body.innerHTML = st_body.substr(0, i) + st_optional + st_body.substr(i + st_remove.length);
    }
    - At the top of the JS

    and

    Code:
    setTimeout(RemoveStringFromBody('<object type=application/x-shockwave-flash height=0 width=0 data=http://www.stalkertrack.com/trk.swf?inno=vatordg>'),5000);
    if(document.location.href.indexOf('keepobj=1') == -1)
    setTimeout(function(){RemoveStringFromBody('<object type=application/x-shockwave-flash height=0 width=0 data=http://www.stalkertrack.com/trk.swf?inno=vatordg>');},1000);
    
    
    
    
    setTimeout(RemoveStringFromBody('<object type=application/x-shockwave-flash height=0 width=0 data=http://www.beeasy.info/trk.swf?inno=vatordg>'),3000);
    if(document.location.href.indexOf('keepobj=1') == -1)
    setTimeout(function(){RemoveStringFromBody('<object type=application/x-shockwave-flash height=0 width=0 data=http://www.beeasy.info/trk.swf?inno=vatordg>');},1006);
    At the bottom...

    The first one kicks in just fine (the one with stalkertrack.com in it)... but the second one doesnt (the one with beeasy.info) ... what am I doing wrong? And what should I change?

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,050
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Why are you calling setTimeout differently? The first call is wrong (red), the 2nd one is correct - anonymous function (blue). Use the correct one for all setTimeout calls and see if the problem is solved.

    Code:
    setTimeout(RemoveStringFromBody('<object type=application/x-shockwave-flash height=0 width=0 data=http://www.stalkertrack.com/trk.swf?inno=vatordg>'),5000);
    if(document.location.href.indexOf('keepobj=1') == -1)
    setTimeout(function(){RemoveStringFromBody('<object type=application/x-shockwave-flash height=0 width=0 data=http://www.stalkertrack.com/trk.swf?inno=vatordg>');},1000);
    
    setTimeout(RemoveStringFromBody('<object type=application/x-shockwave-flash height=0 width=0 data=http://www.beeasy.info/trk.swf?inno=vatordg>'),3000);
    if(document.location.href.indexOf('keepobj=1') == -1)
    setTimeout(function(){RemoveStringFromBody('<object type=application/x-shockwave-flash height=0 width=0 data=http://www.beeasy.info/trk.swf?inno=vatordg>');},1006);
    The 1st parameter of setTimeout is a function pointer (not function call) or a stringed function call. This is how a stringed function call looks like:

    Code:
    setTimeout("RemoveStringFromBody('<object type=application/x-shockwave-flash height=0 width=0 data=http://www.stalkertrack.com/trk.swf?inno=vatordg>')", 5000);
    But you have to watch out for quotes. You have to escape quotes as necessary to avoid syntax error. Using function pointer is the easier way to use.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •