469,315 Members | 1,585 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,315 developers. It's quick & easy.

URL Capture question resolved...need a tweak

DGS
Hi all...

Yesterday I asked about setting a cookie with an intially requested URL that
could be used later. I found the code to do it. For the code on the
login.html page I would like to tweak it to NOT be server specific. Here is
the code for the front end:

<SCRIPT LANGUAGE=JavaScript>
if(document.URL != "https://test2k301/pkmslogin.form"){
document.cookie = ('Referrer_Page='+document.URL)+'; path=/';
}
</SCRIPT>

Anybody know of a way I can make this work with JUST the path? Put in other
words...I'd like for it to check this to look for ONLY "/pkmslogin.form".
However, I still want the cookie to always contain the full URL. This would
effectively make it so I didn't have to change the code to be server
specific for each server this gets copied to.
May 17 '07 #1
4 2300
DGS said the following on 5/17/2007 12:50 PM:
Hi all...

Yesterday I asked about setting a cookie with an intially requested URL that
could be used later. I found the code to do it. For the code on the
login.html page I would like to tweak it to NOT be server specific. Here is
the code for the front end:

<SCRIPT LANGUAGE=JavaScript>
if(document.URL != "https://test2k301/pkmslogin.form"){
document.cookie = ('Referrer_Page='+document.URL)+'; path=/';
}
</SCRIPT>

Anybody know of a way I can make this work with JUST the path? Put in other
words...I'd like for it to check this to look for ONLY "/pkmslogin.form".
However, I still want the cookie to always contain the full URL. This would
effectively make it so I didn't have to change the code to be server
specific for each server this gets copied to.
if (document.URL.indexOf('/pkmslogin.form') != -1)

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 17 '07 #2
DGS

"Randy Webb" <Hi************@aol.comwrote in message
news:u6********************@giganews.com...
DGS said the following on 5/17/2007 12:50 PM:
>Hi all...

Yesterday I asked about setting a cookie with an intially requested URL
that could be used later. I found the code to do it. For the code on
the login.html page I would like to tweak it to NOT be server specific.
Here is the code for the front end:

<SCRIPT LANGUAGE=JavaScript>
if(document.URL != "https://test2k301/pkmslogin.form"){
document.cookie = ('Referrer_Page='+document.URL)+'; path=/';
}
</SCRIPT>

Anybody know of a way I can make this work with JUST the path? Put in
other words...I'd like for it to check this to look for ONLY
"/pkmslogin.form". However, I still want the cookie to always contain the
full URL. This would effectively make it so I didn't have to change the
code to be server specific for each server this gets copied to.

if (document.URL.indexOf('/pkmslogin.form') != -1)
Hmmm...somewhere along the lines this is breaking the functionality and
causing the cookie to get set when /pkmslogin.form is the path...which is
the why the if check is in place...
May 17 '07 #3
DGS said the following on 5/17/2007 2:08 PM:
"Randy Webb" <Hi************@aol.comwrote in message
news:u6********************@giganews.com...
>DGS said the following on 5/17/2007 12:50 PM:
>>Hi all...

Yesterday I asked about setting a cookie with an intially requested URL
that could be used later. I found the code to do it. For the code on
the login.html page I would like to tweak it to NOT be server specific.
Here is the code for the front end:

<SCRIPT LANGUAGE=JavaScript>
if(document.URL != "https://test2k301/pkmslogin.form"){
document.cookie = ('Referrer_Page='+document.URL)+'; path=/';
}
</SCRIPT>

Anybody know of a way I can make this work with JUST the path? Put in
other words...I'd like for it to check this to look for ONLY
"/pkmslogin.form". However, I still want the cookie to always contain the
full URL. This would effectively make it so I didn't have to change the
code to be server specific for each server this gets copied to.
if (document.URL.indexOf('/pkmslogin.form') != -1)

Hmmm...somewhere along the lines this is breaking the functionality and
causing the cookie to get set when /pkmslogin.form is the path...which is
the why the if check is in place...
Change the != to ==

if (document.URL.indexOf('/pkmslogin.form') == -1)

If the indexOf is -1 then the string is not present.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 17 '07 #4
DGS

"Randy Webb" <Hi************@aol.comwrote in message
news:Mo********************@giganews.com...
DGS said the following on 5/17/2007 2:08 PM:
>"Randy Webb" <Hi************@aol.comwrote in message
news:u6********************@giganews.com...
>>DGS said the following on 5/17/2007 12:50 PM:
Hi all...

Yesterday I asked about setting a cookie with an intially requested URL
that could be used later. I found the code to do it. For the code on
the login.html page I would like to tweak it to NOT be server specific.
Here is the code for the front end:

<SCRIPT LANGUAGE=JavaScript>
if(document.URL != "https://test2k301/pkmslogin.form"){
document.cookie = ('Referrer_Page='+document.URL)+'; path=/';
}
</SCRIPT>

Anybody know of a way I can make this work with JUST the path? Put in
other words...I'd like for it to check this to look for ONLY
"/pkmslogin.form". However, I still want the cookie to always contain
the full URL. This would effectively make it so I didn't have to
change the code to be server specific for each server this gets copied
to.
if (document.URL.indexOf('/pkmslogin.form') != -1)

Hmmm...somewhere along the lines this is breaking the functionality and
causing the cookie to get set when /pkmslogin.form is the path...which is
the why the if check is in place...

Change the != to ==

if (document.URL.indexOf('/pkmslogin.form') == -1)

If the indexOf is -1 then the string is not present.
That did the trick! Thanks very much Randy!
May 17 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Me Mine | last post: by
2 posts views Thread by Kim Petersen | last post: by
3 posts views Thread by Juan Crespo | last post: by
5 posts views Thread by ewillyb | last post: by
7 posts views Thread by Lew | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.