473,320 Members | 1,993 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Load different web page from a hyperlink

manuelgk
Hi!, does anybody know how to load a different Web page using a hyperlink?. Now I have my code with some "<a href>" when I click the link, it load the URL of the <a href>. My question is how can I force the navigator with JS to load a different Web page?. For example, if I click the link of google( [HTML]<a href='http://www.google.com.mx'>Google</a>[/HTML] ) the result of the event it will not the google Web page!!!, so the navigator displays a Web page define in my script (for example www.yahoo.com). I know it could be a stupid question, because easily I can change the reference in the <a> tags, but as I said in another discussion, I'm a total beginner and I try new things with JS.

Thank you again!!!
Oct 8 '07 #1
3 1543
gits
5,390 Expert Mod 4TB
hi ...

here's an example, that switches the href of the link when the page is loaded:

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. function switch_href() {
  3.     var l = document.getElementById('my_link');
  4.     l.href = 'your_new_url';
  5. }
  6. </script>
  7.  
  8. <body onload="switch_href();">
  9.     <a id="my_link" href="http://www.google.com.mx">Google</a>
  10. </body>
  11.  
kind regards
Oct 8 '07 #2
Ok got it!, thanks for replied, It's really useful
Oct 8 '07 #3
gits
5,390 Expert Mod 4TB
post back to the forum anytime you have more questions :)

kind regards
Oct 9 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Max | last post by:
Frankly, i need session variables to persist regardless of load balancing. My hoster says save them in files, yuk. Are there any other thoughts The problem is that the session variables are lost...
6
by: dale zhang | last post by:
Hi, I build a web form with a 4-cell table on the top (flawlayout), followed by some labels and textboxes (gridlayout). The web form is displayed well in dell m60 laptop with all resolution...
1
by: Biva | last post by:
Hello, I have a drop down list control in a datagrid. I can't seem to populate the control. Here is what my code looks like: <EditItemTemplate> <asp:DropDownList ID= "ddlUser5" DataSource =...
2
by: Colin Basterfield | last post by:
Hi, Hmmm, a strange one for me, but hopefully not for others... I have a base page which has virtual protected void PageLoadEvent(object sender, System.EventArgs e){} In the Page_Load...
3
by: Shapper | last post by:
Hello, I am working on an ASP.NET/VB web site. I have several links including menu links. Considerer a want to load a page named page.aspx. I can do it using javascript. Or using this code:...
2
by: Rob R. Ainscough | last post by:
In my code behind (VB.NET 2.0), I've been using Response.Redirect("mypage.aspx") to navigate from one page to the next. What I'd like to do now is load a new browser window and load it with the...
1
by: R.A.M. | last post by:
Hello, (Sorry for my English...) Could you help me please? I have little experience. I have a page with a hyperlink to another one. When hyperlink is clicked the second page is not displayed...
0
by: LaptopHeaven | last post by:
I am having some trouble. How would one load a custom UserControl fro within a class which impements the ITemplate interface. Currently I have the following: public class...
4
hemantbasva
by: hemantbasva | last post by:
We have designed an aspx page having five ajax tab in it. the data of first four are designed on page whereas for the fifth tab it renders a user control named MYDOMAIN. in the tab container's even...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.