Help for a javascript decrepit

S

splatter

Hey all,

I'm trying to get a java bookmark to work from my browsers address field
which is supposed to send a prefix + reload the current page from my proxy
&
return a special view depending on the prefix. "src=source, dbug=debug,
bypass=ignore all filters" etc....

So what is wrong with these? I'm only listing two.

I have tried
"javascript:document.nolocation="http://src//"+document.nolocation.href.sub
string(7);"

&

"javascript:document.NoLocation="http://dbug//"+document.NoLocation.href.su
bstring(7);"

I keep getting:
Error: document.nolocation has no properties
Source File:

javascript:document.nolocation="http://src.."+document.nolocation.href.subst
ring(7);
Line: 1

Thanks in advance.

DP
 
S

Stuart Palmer

Firstly Javascript isn't Java.

What are 'nolocation' and 'NoLocation'?

I personally don't get what you are trying to do can you explain in more
detail please? Give example of the urls you have when you start and what you
are wanting to get and how you are wanting to get them....drop down/link etc
might help)

Cheers

Stu
 
S

splatter

"javascript:document.nolocation="http://src//"+document.nolocation.href.sub
"javascript:document.NoLocation="http://dbug//"+document.NoLocation.href.su
javascript:document.nolocation="http://src.."+document.nolocation.href.subst

Stuart Palmer said:
Firstly Javascript isn't Java.

What are 'nolocation' and 'NoLocation'?

I personally don't get what you are trying to do can you explain in more
detail please? Give example of the urls you have when you start and what you
are wanting to get and how you are wanting to get them....drop down/link etc
might help)

Cheers

Stu

Top post fixed.

There is no URL Stu. What I am trying to do is have a bookmark in my browser
that when clicked opens this location in the address bar:
"javascript:document.nolocation="http://src//"+document.nolocation.href.subs
tring(7);"

Which is supposed to pass the prefix http://src// while reloading the
currently viewed page. The result is then caught by my proxy and is supposed
to return with a reformatted view of the page depending on the command
passed between the "//..//". This is all documented by my proxys help file.
The only problem is the command they are using is not recognized and I am
getting a undefined variable error.

So my question is, what am I doing wrong?

DP
 
R

Richard Cornford

Top post fixed.

Fair enough, but there are good arguments for also trimming material
that you are not directly responding to rather that quoting the entire
preceding thread verbatim.
There is no URL Stu. What I am trying to do is have a bookmark
in my browser that when clicked opens this location in the
address bar:
"javascript:document.nolocation="http://src//"+document.
nolocation.href.substring(7);"

Which is supposed to pass the prefix http://src// while
reloading the currently viewed page. ...
<snip>

In a normal browser DOM there is no document.nolocation object, which
makes the proxy's suggested javascript URL odd. It is possible that
your proxy is content inserting/re-writing and under some circumstances
it will screw around with the document.location object and create a
nolocation property with it, but if you are getting an "object has no
properties" error that obviously is not currently the case with your
set-up. (if your proxy is content inserting/re-writing then looking at
the resulting page source might be necessary to work out what it is up
to)

It is the location object that you should be reading and assigning
values to, but document.location is usually not the best choice of
location objects to use, instead window.location is preferred (though if
you are working with a known browser that might not be important).
window.location is a global property so it can be referred to as just -
location -.

The next consideration is that the javascript pseudo-protocol URL is
designed so that a string returned will be used as the contents of a new
page that replaces the current page. As you have your URL now it is
returning a string value form the assignment expression. While setting
the location object should prevent the javascript pseudo-protocol return
value from replacing the current page it is normal (and probably safer)
to ensure that the javascript URL returns an undefined value. That is
easiest achieved by using the - void - operator on the expression. Which
leaves the javascript URL looking something like:-

javascript:void (location="http://src//"+location.href.substring(7));

You could test that the constructed string is what you expect by using
the alert function in a similar javascript URL:-

javascript:alert("http://src//"+location.href.substring(7));

Richard.
 
G

Graham J

There is no URL Stu. What I am trying to do is have a bookmark in my
browser
that when clicked opens this location in the address bar:
"javascript:document.nolocation="http://src//"+document.nolocation.href.subs
tring(7);"

Which is supposed to pass the prefix http://src// while reloading the
currently viewed page. The result is then caught by my proxy and is supposed
to return with a reformatted view of the page depending on the command
passed between the "//..//". This is all documented by my proxys help file.
The only problem is the command they are using is not recognized and I am
getting a undefined variable error.

So my question is, what am I doing wrong?

I could be way off but is it possible that you have your web filtering proxy
configured to rewrite "document.location" in pages with
"document.nolocation" but with a delicious irony you are reading the
documentation through this proxy and so seeing the instructions rewritten
too?

To put it another way, does it work any better with document.location in the
above?
 
S

splatter

Hoorah.. Thanks guys as a matter of fact both of them work

javascript:document.location="http://src//"+document.location.href.substring
(7);

&

javascript:void (location="http://src//"+location.href.substring(7));

Thanks again,

David P.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top