Click to See Complete Forum and Search --> : general architectural considerations (obtaining a windows URL)
chriskuku
01-12-2003, 09:33 AM
Hi, I'm new to this forum. My experience in Javascript is inferior. I'm asking for some advice here how to approach the following problem:
I want to click with the mouse pointer into a window (in which a web page currently is displayed) and pass the URL of this page as an argument for a subsequent Web page invocation.
During this procedure the cursor should take a
different shape, e.g. looking glasses or something. I also would like to embed the cursor shape into the javascript code to avoid lookup of a file which otherwise would have to be redistributed with the javascript code fragment.
Any suggestions?
Michael Dibbets
01-12-2003, 10:03 AM
well, in a page use this(this can only be tested if a page is online, not if a page is on your local harddrive!!!!!
put this in your first page(replace blah.html with the name of the other HTML file)
<a href="javascript:;" onclick="self.location.href='blah.html?URL='+self.location.href" style="curser:crosshair">click here</a>
now we have that done paste this in your other web page, right under the body tag.
// getting the full url of this page
url = self.location.href;
// getting rid off the stuff we don't need
tmparr = url.split("?");
// now we get all data we need.(names & value pairs)
tmparr = tmparr[1].split("=");
// we are going to walk through all name & value pairs to see if the one we need is present
for(c=0;c<tmparr.length;c=c+2)
{
// the one we need, if it's found we will asign the value to the variable url.
if(tmparr[c].indexOf("URL") != -1)
{
url = tmparr[c+1];
we've found what we need so now we'll quit the loop
break;
}
}
// display the variable to see if it worked out rightly
window.alert(url);
Well, I hope I've been some help
chriskuku
01-12-2003, 10:35 AM
Originally posted by Michael Dibbets
well, in a page use this(this can only be tested if a page is online, not if a page is on your local harddrive!!!!!
put this in your first page(replace blah.html with the name of the other HTML file)
<a href="javascript:;" onclick="self.location.href='blah.html?URL='+self.location.href" style="curser:crosshair">click here</a>
now we have that done paste this in your other web page, right under the body tag.
// getting the full url of this page
url = self.location.href;
// getting rid off the stuff we don't need
tmparr = url.split("?");
// now we get all data we need.(names & value pairs)
tmparr = tmparr[1].split("=");
// we are going to walk through all name & value pairs to see if the one we need is present
for(c=0;c<tmparr.length;c=c+2)
{
// the one we need, if it's found we will asign the value to the variable url.
if(tmparr[c].indexOf("URL") != -1)
{
url = tmparr[c+1];
we've found what we need so now we'll quit the loop
break;
}
}
// display the variable to see if it worked out rightly
window.alert(url);
Well, I hope I've been some help
Thanks. Let me ask some questions:
What does the href"javascript:;" mean? It produces an error, when I click the link. An alert box pos up saying that netscape is unable to find file or directory. Ah, you are saying that it won't work when the file is on my hard drive, sorry.
I have no influence to put that code into the URL I'm visiting. Let me explain the scenario again:
Assumed you have a button in a left frame or some other browser window or a button in the personal bookmark bar in the browser. In another browser window or frame you have the web page in question,
e.g. www.netscape.com.
Now the sequence should be the following:
click on the button (in frame, window or toolbar),
cursor shape should change into looking glasses (if possible, an own developed shape). With this
cursor shape now click into the web page www.netscape.com. Obtain the URL from this pick. I found that document.URL would do the job and invoke another URL with this URL as argument.
Think of the whole a s translator. Click the translotor button english-to-german, then click the english page, send this page's URL to the translator machine at a different URL.
(finally this translator machine fetches the URL and produces the result).
Thanks.