Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Part of URL is getting discarded

Reply
Thread Tools

Part of URL is getting discarded

 
 
Howard Kaikow
Guest
Posts: n/a
 
      10-09-2004
How do I find where I am screwing up?

Using the following in Eudora, and equivalent links elsewhere, the URLs with
the # get truncated just before the #.

<a href="http://www.standards.com/links.html?FailureToDeleteToolbar"
eudora="autourl">http://www.standards.com/links.html?FailureToDeleteToolbar<
br><br>
</a><a href="http://www.standards.com/links.html#FailureToDeleteToolbar"
eudora="autourl">http://www.standards.com/links.html#FailureToDeleteToolbar<
br><br>
</a><a href="http://www.standards.com/links.html?HowardKaikow"
eudora="autourl">http://www.standards.com/links.html?HowardKaikow<br><br>
</a><a href="http://www.standards.com/links.html#HowardKaikow"
eudora="autourl">http://www.standards.com/links.html#HowardKaikow<br><br>

If I include alert(location.href), the URL is truncated on input to the
script.
For example, http://www.standards.com/links.html#...oDeleteToolbar gets
truncated to http://www.standards.com/links.html.
No problem if a ? is used instead of a #.

However, the following does not truncate the URL.

<p><a
href="links.html#FailureToDeleteToolbar">#FailureT oDeleteToolbar</a></p>
<p><a
href="links.html?FailureToDeleteToolbar">?FailureT oDeleteToolbar</a></p>

I expect that I am doing something wrong.
Any pointers?

function CompareBookmarks(bmkTarget)
{
return (locSearch== bmkTarget.toLowerCase());
}
var locHash=location.hash.toLowerCase().slice(1);
var locSearch=location.search.toLowerCase().slice(1);
var lenHash=locHash.length;
var lenSearch=locSearch.length;
var blnStatus=Boolean(false);
alert(location.href);
if((lenHash != 0) && (lenSearch != 0) || ((lenHash + lenSearch) == 0))
{
blnStatus = false;
}
else
{
blnStatus = true;
if(lenSearch == 0)
{
locSearch = locHash;
}
}
if (blnStatus)
{
if(CompareBookmarks("HowardKaikow")){
location.replace("HowardKaikow.html");
}
else if(CompareBookmarks("HowardKaikowServices")){
location.replace("HowardKaikowServices.html");
}
else if(CompareBookmarks("SortPerformanceComparison")){
location.replace("Sorting/SortPerformanceComparison-Description.html");
}
else if(CompareBookmarks("ThisandThat")){
location.replace("index.html#ThisandThat");
}
else if(CompareBookmarks("CopyFileToPrinter")){
location.replace("ThisAndThat/CopyFileToPrinter.html");
}
else if(CompareBookmarks("WordVBABooks")){
location.replace("OhMyWord/WordVBABooks.htm");
}
else if(CompareBookmarks("WordBasicBooks")){
location.replace("OhMyWord/WordBasicBooks.htm");
}
else if(CompareBookmarks("FailureToDeleteToolbar")){
location.replace("OhMyWord/VBABugsFeatures/FailureToDeleteToolbar.html");
}
else if(CompareBookmarks("SetReferenceInWordProject")){
location.replace("OhMyWord/SetReferenceInWordProject.html");
}
else {
alert(location.href + " is not a valid URL.\n" +
"You will be taken to http://www.standards.com/index.html.");
location.replace("index.html");
}
}
else {
alert(location.href + " is not a valid URL.\n" +
"You will be taken to http://www.standards.com/index.html.");
location.replace("index.html");
}






--
http://www.standards.com/; See Howard Kaikow's web site.


 
Reply With Quote
 
 
 
 
McKirahan
Guest
Posts: n/a
 
      10-09-2004
"Howard Kaikow" <(E-Mail Removed)> wrote in message
news:ck9pii$rsv$(E-Mail Removed)...
> How do I find where I am screwing up?
>
> Using the following in Eudora, and equivalent links elsewhere, the URLs

with
> the # get truncated just before the #.
>
> <a href="http://www.standards.com/links.html?FailureToDeleteToolbar"
>

eudora="autourl">http://www.standards.com/links.html?FailureToDeleteToolbar<
> br><br>
> </a><a href="http://www.standards.com/links.html#FailureToDeleteToolbar"
>

eudora="autourl">http://www.standards.com/links.html#FailureToDeleteToolbar<
> br><br>
> </a><a href="http://www.standards.com/links.html?HowardKaikow"
> eudora="autourl">http://www.standards.com/links.html?HowardKaikow<br><br>
> </a><a href="http://www.standards.com/links.html#HowardKaikow"
> eudora="autourl">http://www.standards.com/links.html#HowardKaikow<br><br>
>
> If I include alert(location.href), the URL is truncated on input to the
> script.
> For example, http://www.standards.com/links.html#...oDeleteToolbar

gets
> truncated to http://www.standards.com/links.html.
> No problem if a ? is used instead of a #.
>
> However, the following does not truncate the URL.
>
> <p><a
> href="links.html#FailureToDeleteToolbar">#FailureT oDeleteToolbar</a></p>
> <p><a
> href="links.html?FailureToDeleteToolbar">?FailureT oDeleteToolbar</a></p>
>
> I expect that I am doing something wrong.
> Any pointers?
>
> function CompareBookmarks(bmkTarget)
> {
> return (locSearch== bmkTarget.toLowerCase());
> }
> var locHash=location.hash.toLowerCase().slice(1);
> var locSearch=location.search.toLowerCase().slice(1);
> var lenHash=locHash.length;
> var lenSearch=locSearch.length;
> var blnStatus=Boolean(false);
> alert(location.href);
> if((lenHash != 0) && (lenSearch != 0) || ((lenHash + lenSearch) == 0))
> {
> blnStatus = false;
> }
> else
> {
> blnStatus = true;
> if(lenSearch == 0)
> {
> locSearch = locHash;
> }
> }
> if (blnStatus)
> {
> if(CompareBookmarks("HowardKaikow")){
> location.replace("HowardKaikow.html");
> }
> else if(CompareBookmarks("HowardKaikowServices")){
> location.replace("HowardKaikowServices.html");
> }
> else if(CompareBookmarks("SortPerformanceComparison")){
> location.replace("Sorting/SortPerformanceComparison-Description.html");
> }
> else if(CompareBookmarks("ThisandThat")){
> location.replace("index.html#ThisandThat");
> }
> else if(CompareBookmarks("CopyFileToPrinter")){
> location.replace("ThisAndThat/CopyFileToPrinter.html");
> }
> else if(CompareBookmarks("WordVBABooks")){
> location.replace("OhMyWord/WordVBABooks.htm");
> }
> else if(CompareBookmarks("WordBasicBooks")){
> location.replace("OhMyWord/WordBasicBooks.htm");
> }
> else if(CompareBookmarks("FailureToDeleteToolbar")){
> location.replace("OhMyWord/VBABugsFeatures/FailureToDeleteToolbar.html");
> }
> else if(CompareBookmarks("SetReferenceInWordProject")){
> location.replace("OhMyWord/SetReferenceInWordProject.html");
> }
> else {
> alert(location.href + " is not a valid URL.\n" +
> "You will be taken to http://www.standards.com/index.html.");
> location.replace("index.html");
> }
> }
> else {
> alert(location.href + " is not a valid URL.\n" +
> "You will be taken to http://www.standards.com/index.html.");
> location.replace("index.html");
> }
>
>
>
>
>
>
> --
> http://www.standards.com/; See Howard Kaikow's web site.
>
>



 
Reply With Quote
 
 
 
 
McKirahan
Guest
Posts: n/a
 
      10-09-2004
"Howard Kaikow" <(E-Mail Removed)> wrote in message
news:ck9pii$rsv$(E-Mail Removed)...
> How do I find where I am screwing up?
>
> Using the following in Eudora, and equivalent links elsewhere, the URLs

with
> the # get truncated just before the #.
>
> <a href="http://www.standards.com/links.html?FailureToDeleteToolbar"
>

eudora="autourl">http://www.standards.com/links.html?FailureToDeleteToolbar<
> br><br>
> </a><a href="http://www.standards.com/links.html#FailureToDeleteToolbar"
>

eudora="autourl">http://www.standards.com/links.html#FailureToDeleteToolbar<
> br><br>
> </a><a href="http://www.standards.com/links.html?HowardKaikow"
> eudora="autourl">http://www.standards.com/links.html?HowardKaikow<br><br>
> </a><a href="http://www.standards.com/links.html#HowardKaikow"
> eudora="autourl">http://www.standards.com/links.html#HowardKaikow<br><br>
>
> If I include alert(location.href), the URL is truncated on input to the
> script.
> For example, http://www.standards.com/links.html#...oDeleteToolbar

gets
> truncated to http://www.standards.com/links.html.
> No problem if a ? is used instead of a #.
>
> However, the following does not truncate the URL.
>
> <p><a
> href="links.html#FailureToDeleteToolbar">#FailureT oDeleteToolbar</a></p>
> <p><a
> href="links.html?FailureToDeleteToolbar">?FailureT oDeleteToolbar</a></p>
>
> I expect that I am doing something wrong.
> Any pointers?



For me these all returned the entire link.

<html>
<head>
<title>HK.htm</title>
<script type="text/javascript">
alert(location.href)
</script>
</head>
<body>
<br><a href="http://localhost/HK.htm#Test">http://localhost/HK.htm#Test</a>
<br><a href="http://localhost/HK.htm?Test">http://localhost/HK.htm?Test</a>
<br><a href="HK.htm#Test">HK.htm#Test</a>
<br><a href="HK.htm?Test">HK.htm?Test</a>
</html>


 
Reply With Quote
 
Howard Kaikow
Guest
Posts: n/a
 
      10-10-2004
"McKirahan" <(E-Mail Removed)> wrote in message
news:zC_9d.363482$Fg5.201272@attbi_s53...
> > </a><a href="http://www.standards.com/links.html#FailureToDeleteToolbar"
> > </a><a href="http://www.standards.com/links.html#HowardKaikow"
> > For example, http://www.standards.com/links.html#...oDeleteToolbar

> For me these all returned the entire link.


THe only ones that fail for me are those above.

For example, all links in http://www.standards.com/testrefs.html work, or
not, as expected.

Sumptin's not right somewhere.

>
> <html>
> <head>
> <title>HK.htm</title>
> <script type="text/javascript">
> alert(location.href)
> </script>
> </head>
> <body>
> <br><a

href="http://localhost/HK.htm#Test">http://localhost/HK.htm#Test</a>
> <br><a

href="http://localhost/HK.htm?Test">http://localhost/HK.htm?Test</a>
> <br><a href="HK.htm#Test">HK.htm#Test</a>
> <br><a href="HK.htm?Test">HK.htm?Test</a>
> </html>
>
>



 
Reply With Quote
 
Lee
Guest
Posts: n/a
 
      10-10-2004
Howard Kaikow said:
>
>"McKirahan" <(E-Mail Removed)> wrote in message
>news:zC_9d.363482$Fg5.201272@attbi_s53...
>> > </a><a href="http://www.standards.com/links.html#FailureToDeleteToolbar"
>> > </a><a href="http://www.standards.com/links.html#HowardKaikow"
>> > For example, http://www.standards.com/links.html#...oDeleteToolbar

>> For me these all returned the entire link.

>
>THe only ones that fail for me are those above.
>
>For example, all links in http://www.standards.com/testrefs.html work, or
>not, as expected.


All of them that are valid URL's work fine for me in Firefox.
Some that are not valid are:
#NoSuchBookmark
?HowardKaikow#HowardKaikow
#HowardKaikow?HowardKaikow

 
Reply With Quote
 
Michael Winter
Guest
Posts: n/a
 
      10-10-2004
On 9 Oct 2004 21:57:24 -0700, Lee <(E-Mail Removed)> wrote:

[snip]

> Some that are not valid are:
> #NoSuchBookmark
> ?HowardKaikow#HowardKaikow


I'm not sure if that is invalid. According to a quick read of RFC 2396[1],
that URI would refer to the current resource with a respecified query
string and fragment identifier. Still, it should probably be avoided just
like the empty URI. Whilst IE does apply "?query" properly (though not
""), NN4 doesn't and other browsers might fail, too.

> #HowardKaikow?HowardKaikow


This is certainly invalid. If a fragment identifier is specified, it
should be the last part of the URI.

Mike


[1] Currently a draft standard, but I expect earlier standards agree here.

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
 
Reply With Quote
 
Howard Kaikow
Guest
Posts: n/a
 
      10-10-2004
"Lee" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Howard Kaikow said:
> >For example, all links in http://www.standards.com/testrefs.html work,

or
> >not, as expected.

>
> All of them that are valid URL's work fine for me in Firefox.
> Some that are not valid are:
> #NoSuchBookmark
> ?HowardKaikow#HowardKaikow
> #HowardKaikow?HowardKaikow


Yes, the script specifically disallows the above 3. The ones in
testhref.html all work as expected.
What I do not understand is why the following two fail:

<a href="http://www.standards.com/links.html#FailureToDeleteToolbar"</a>
</a><a href="http://www.standards.com/links.html#HowardKaikow"</a>

I can understand if we found an error in the script, but
alert(location.href) returns a truncated URL upon entering the script for
the two cases above. So the issue boils down to, why is the URL getting
truncated?


 
Reply With Quote
 
Howard Kaikow
Guest
Posts: n/a
 
      10-10-2004
"Michael Winter" <(E-Mail Removed)> wrote in message
newspsfndk3iix13kvk@atlantis...
> On 9 Oct 2004 21:57:24 -0700, Lee <(E-Mail Removed)> wrote:
>
> [snip]
>
> > Some that are not valid are:
> > #NoSuchBookmark
> > ?HowardKaikow#HowardKaikow

>
> I'm not sure if that is invalid. According to a quick read of RFC 2396[1],
> that URI would refer to the current resource with a respecified query
> string and fragment identifier. Still, it should probably be avoided just
> like the empty URI. Whilst IE does apply "?query" properly (though not
> ""), NN4 doesn't and other browsers might fail, too.
>
> > #HowardKaikow?HowardKaikow

>
> This is certainly invalid. If a fragment identifier is specified, it
> should be the last part of the URI.


My script excludes any URL with both a # and a ? because those would not be
valid for redirections I am doing.


 
Reply With Quote
 
Howard Kaikow
Guest
Posts: n/a
 
      10-10-2004
To simplify isolating the problem, I've created the following test.

Using http://www.standards.com/test.html, I find that ALL URLs that have a #
get truncated by location .href (see
http://www.standards.com/testlinnks.html).


 
Reply With Quote
 
Howard Kaikow
Guest
Posts: n/a
 
      10-11-2004
"Howard Kaikow" <(E-Mail Removed)> wrote in message
news:ckbl43$m52$(E-Mail Removed)...
> To simplify isolating the problem, I've created the following test.
>
> Using http://www.standards.com/test.html, I find that ALL URLs that have a

#
> get truncated by location .href (see
> http://www.standards.com/testlinnks.html).



http://www.standards.com/testlinnks.html should have been
http://www.standards.com/testlinks.html.

I just tried from IE 4 on an old Win 95 system, same problem, location.href
truncates the # and anything to the right.
Normally, I (ab)use IE 6 on Win 2000.

Could this be an Apache server issue??


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why does the value get discarded in this case? Chad C Programming 11 06-07-2007 08:39 AM
Cisco VPN client, packets beeing discarded and bypassed seansan Cisco 3 09-24-2006 10:50 AM
Fraudsters stealing personal details from discarded computers tedrichardson9925@sbcglobal.net Computer Information 2 08-21-2006 09:32 PM
discarded iterator.next() at interactive global scope doesn't bump interator?? Bengt Richter Python 2 09-04-2005 12:17 PM
Linker Message: "discarded section" Hartmut Sbosny C++ 2 05-29-2005 12:20 AM



Advertisments