Forum Moderators: open

Message Too Old, No Replies

Passing a variable to a new html page

Passing a "URL" text as a variable to a new page

         

Rajiv

5:10 am on Jul 13, 2004 (gmt 0)

10+ Year Member



Hi..

I have a html page with lot of URLs like [abc.com...]
[xyz.com...] and so on...

Now, I have a page "urldescription.html" which speaks few common issues about all these above domains.

There are instances where I need to use the text "http://www.abc.com" on the page "urldescription" when somebody clicks this particular hyperlink.

My problem is that the text content on the page "urldescription.html" is same for all the URL's listed while I need to use the URL text at some instances to give a customized look.

So, when somebody clicks on any of these hyperlinks the page "urldescription.html" should open with the respective domain name being used at appropriate locations in the text.

This means I need to receive the URL text as a parameter when somebody clicks on that URL.

Remember, we are not using any forms to pass hidden values. Instead, we are clicking on the hyperlink where that hyperlink text is passed as a URL.

Hope my problem is clear.

Let me know your thoughts and if anybody can please help!

With warm regards
Rajiv

Rambo Tribble

5:26 am on Jul 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not entirely clear on what you wish to do, but see if this helps: If you include an onclick event handler in your link, it can initiate a function which, through the DOM, can read the value of the href. Additionally it can cancel the link itself by returning false from the function called. Alternatively, it can allow the link to proceed by returning true.

Any traction?

Rajiv

8:49 am on Jul 13, 2004 (gmt 0)

10+ Year Member



Thank you Rambo for your input... I'll try what you've explained. However, it would be very kind of you if you can paste the code so that it will be easy for me.

Further, as you've stated that the problem is not clear, I'd like to explain it again :

I have a page (say a.html) which list of domain name/URLs like :

[abc.com...]
[xyz.com...]
[yourdomain.com...] and so on..

I want to give a hyperlink to each of these links to a html page (say b.html) (<a href="b.html">http://www.abc.com</a> and so on..) which has few paragraph of text with common text content explaining about each URL.

An example of the text on b.html is as follows :

"Welcome to [abc.com....] We are pleased to know that you've visited our website [abc.com."...] and so on..

Now, if you notice there are 2 instances of the text "http://www.abc.com" appearing above. This happens when anybody clicks on [abc.com...] from the a.html page. Similarly I want this to be replaced as a variable where the URL is passed as a parameter.

For example the above text with variable would look like :

"Welcome to <variable>. We are pleased to know that you've visited our website <variable>." and so on..

I hope you got my point now!

Let me know if you have any doubts. I'll be pleased to explain you.

Once again thank you for your input and I'll try what you've said. Meanwhile, if you can send me the code it would help me a lot.

With warm regards
Rajiv

Rambo Tribble

1:22 pm on Jul 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Okay, I think I've got it. You want to basically have a template that you fill the selected URL into, right?

Try placing the following in a page and see if it gives you any ideas (note that it would be necessary to return true for the link to execute).

<a href="abc.com" onclick="alert(this.href);return false;">click here</a>

Also, you could give the original a tag an id, say aTag1, and call it like this:

document.getElementById("aTag1").href

Rambo Tribble

10:41 pm on Jul 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



When you say passing between pages, unless one is a window of the other you will have to pass the variables through a session cookie.