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 11 of 11
  1. #1
    New Coder hedbanger's Avatar
    Join Date
    Jun 2002
    Location
    vallejo, ca
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts

    replacing part of a string in a variable

    i have sites that use webtrendslive remotely-hosted traffic reporting.
    a couple of the sites are now using .jsp and the complete url isn't being reported because of the "?" in the url string. i want to make it so that the variable that reports the url replaces the "?" with "-" so that the whole url will be sent and the page title will get reported.
    that variable is:
    Code:
    var wtl_URL= document.URL;
    i think it should be something like this, but i'm not sure.
    Code:
    var wtl_URL= document.URL;
    document.URL.replace(\?,"-");
    thanks.
    jf~ if you're not part of the solution, you're part of the precipitate.

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The regular expression to replace all instances of ? with - is: replace(/\?/g,'-')

  • #3
    New Coder hedbanger's Avatar
    Join Date
    Jun 2002
    Location
    vallejo, ca
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts
    willy,
    thanks. there is only one "?" in the url, but i could use what you supplied except i'm unclear on the extra slash in front of the escaped "?".
    replace(/\?/g,'-')

    other questions:
    1. do i have the two lines in the correct order or should they be reversed?
    2. do i need to declare a new variable? (i need to preserve the variable "wtl_URL".
    jf~ if you're not part of the solution, you're part of the precipitate.

  • #4
    New Coder hedbanger's Avatar
    Join Date
    Jun 2002
    Location
    vallejo, ca
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts
    how's this? what am i leaving out?
    i've been looking here and elsewhere for pointers but am still having trouble.
    var wtl_URL= document.URL;
    var new= wtl_URL.replace((/\?/g,'-')
    var wtl_Title= document.title;

    please help me out!
    thanks,
    joan
    jf~ if you're not part of the solution, you're part of the precipitate.

  • #5
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I do not understand what you are doing.
    For instance, how are you using new after you replace (?) with (-)???

    You will need to provide more information.
    Such as all of the relevant code so someone can make an informed assessment.....

    .....Willy

  • #6
    New Coder hedbanger's Avatar
    Join Date
    Jun 2002
    Location
    vallejo, ca
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i'm sorry! here is the original script:
    Code:
    var wtl_URL= document.URL;
    var wtl_Title= document.title;
    i was basing my changes on this model:
    Code:
    var old=window.document.URL
    var new=old.replace(\?,'-')
    webtrendslive is remotely hosted and the pages that have the script in them report back traffic and browser info. then the info is available on their website.
    the .jsp content is dynamically placed inside of one of 6 container pages.
    the url before the "?" corresponds to those container pages such as "ProductLine." in
    Code:
    http://www.anolon.com/anolon/ProductLine.jsp?channelid=a808a74c94196f00vcm1000000001f00000a____
    link to actual page
    when the full url loads, including the string after the "?", the correct page title is displayed, which in this case is "advanced clad".
    (the way it's set up, "productline" is a "channel" and the productlines below it are "subchannels".)

    when a page is hit, the url is sent to webtrendslive. once a page has been reported, it always reports the same page title. and since it's detecting only the url up to the "?", it's reporting "ProductLine" instead of the dozen different product lines that are subchannels.
    so, if i can get the full string to report to webtrendslive, then it should detect and report the correct page title.

    so what i need to do is to replace the "?" so the url won't get truncated, but preserve the original variable name "wtl_URL" so remote script will still work.
    i hope this makes things clearer.
    thanks in advance for your help.
    joan
    jf~ if you're not part of the solution, you're part of the precipitate.

  • #7
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by hedbanger
    when a page is hit, the url is sent to webtrendslive. once a page has been reported, it always reports the same page title. and since it's detecting only the url up to the "?", it's reporting "ProductLine" instead of the dozen different product lines that are subchannels.
    so, if i can get the full string to report to webtrendslive, then it should detect and report the correct page title.

    so what i need to do is to replace the "?" so the url won't get truncated, but preserve the original variable name "wtl_URL" so remote script will still work.
    i hope this makes things clearer.
    thanks in advance for your help.
    joan
    Your link provided us with what we needed to see.
    (the webtrends script)

    Code:
    <script language="JavaScript" type="text/JavaScript">
    <!--
    <!-- START OF WEBTRENDS LIVE TAG -->
    <!-- Copyright 2003 NetIQ Corporation -->
    <!--  For privacy concerns, check our Privacy Policy at http://www.webtrendslive.com/wtl_sys...acy_policy.htm -->
    <!--
    // Modification of this code is not allowed and will permanently disable your account!
    // SiteName:  Anolon
    function wtl_Tag5_37748()
    {
    	var SERVER= "";
    	var CONTENTGROUP= "";
    	var wtl_Title= document.title;
    	var wtl_URL= document.URL;
    	var wtl_URL= wtl_URL.replace(\?,'-');
    	
    	
    
    	function D8( d)
    	{
    		var fwd=0, seed= new Date('01/01/2000'), key= "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
    		var s= key.charAt( d.getFullYear()-2000)+key.charAt( d.getMonth()+1)+key.charAt( d.getDate());
    		s+= key.charAt( d.getHours())+key.charAt( d.getMinutes())+key.charAt( d.getSeconds());
    		while( seed.getDay()!=fwd) seed= new Date(seed.getTime() + 86400000);
    		var w= Math.floor( (d.getTime()-(seed.getTime()+86400000)) / 604800000 );
    		s+= key.charAt( (w-(w%16))/16 );
    		s+= key.charAt( w%16);
    		return s;
    	}
    	
    	function A( B, C)
    	{
    		W+="&"+B+"="+escape(C);
    	}
    
    	var t = new Date();
    	var W="http"+(document.URL.indexOf('https:')==0?'s':'')+"://statse.webtrendslive.com/S009-00-11-22-206521-37748/button5.asp?tagver=5&si=37748&fw=0";
    	A( "server", typeof(SERVER)== "string" ? SERVER : "");
    	A( "Group", typeof(CONTENTGROUP)== "string" ? CONTENTGROUP : "");
    	A( "tz", t.getTimezoneOffset());
    	A( "ch", t.getHours());
    	A( "cl", D8(t));
    	A( "ti", typeof(wtl_Title)== "string" ? wtl_Title : document.title);
    	A( "url", typeof(wtl_URL)== "string" ? wtl_URL : document.URL);
    	A( "rf", window.document.referrer);
    	A( "js", "Yes");
    	A( "ul", navigator.appName=="Netscape" ? navigator.language : navigator.userLanguage);
    	if(typeof(screen)=="object")
    	{
    	A( "sr", screen.width+"x"+screen.height);
    	A( "cd", screen.colorDepth);
    	A( "jo", navigator.javaEnabled()?"Yes":"No");
    	}
    	if( W.length>2048 && navigator.userAgent.indexOf('MSIE')>=0)
    		W= W.substring( 0, 2043)+"&tu=1";
    
    	document.write('<IMG ID="WTL_37748" BORDER="0" WIDTH="1" HEIGHT="1" SRC="'+W+'">');
    }
    
    wtl_Tag5_37748();
    //-->
    <!-- END OF WEBTRENDS LIVE TAG -->
    //-->
    </script>
    No, wtl_URL has nothing to do with reporting the document title. Webtrends script is sending the document.title from the variable wtl_Title. If you wish to find the subchannel which includes everything after the querry (?) you will need to strip that from webtrends report and I can not offer any solutions to that since I havent seen the report.

    All that aside, what you are trying to do is against Webtrends TOS and is clearly stated within the comments of the script that any modifications to the script will terminate your account. Therefore, noone here will help you (for whatever reasons) modify the codes which you agreed not too when you opened your account with Webtrends.

    Perhaps if you can post a brief copy of the report indicating how wtl_URL is reported, someone could help you strip out the necassary info in order to figure out which subchannel has been called, how many times.

    .....Willy

  • #8
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    FWIW: Why don't you try this free stat counter. I believe it will properly report pages loaded into php or jsp index pages......

  • #9
    New Coder hedbanger's Avatar
    Join Date
    Jun 2002
    Location
    vallejo, ca
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts
    willy,
    yes, '
    i'm aware of the TOS issue. but that's to cover when alterations to the code cause a severe problem, and this won't. (i was told that the only problem in this case would be if the query strings were over 300 characters long -- and they aren't.)

    you are correct and i know also, that the variable wtl_URL doesn't convey the title, but it can't get the correct title unless the FULL url with the query for the subchannel is conveyed.

    anyway, thanks for your input. i will keep working on this.
    joan
    jf~ if you're not part of the solution, you're part of the precipitate.

  • #10
    New Coder hedbanger's Avatar
    Join Date
    Jun 2002
    Location
    vallejo, ca
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts
    FWIW: Why don't you try this free stat counter. I believe it will properly report pages loaded into php or jsp index pages......
    thanks. i'll check that one out for other uses.

    it's what WTL does with the stats that's important! the WTL reports are very comprehensive -- about 95 pages long. they're the darling of the marketing department.

    but there are other log processing apps that i'll be looking into. the sites use websphere and vignette, both of which probably have apps and they may already be part of the license.
    j
    jf~ if you're not part of the solution, you're part of the precipitate.

  • #11
    New Coder hedbanger's Avatar
    Join Date
    Jun 2002
    Location
    vallejo, ca
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up got it!

    thanks to you, willy and the netscape 7.1 java console, it looks like it is working.
    Code:
    var wtl_URL= document.URL;
    var wtl_URL= wtl_URL.replace(/\?/g,'-');
    var wtl_Title= document.title;
    jf~ if you're not part of the solution, you're part of the precipitate.


  •  

    Posting Permissions

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