Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hyperlink Question 2

Status
Not open for further replies.

FontanaS

Programmer
May 1, 2001
357
0
0
US
Hello,

I would like to have a hyperlink that when clicked on, displays a message box to the user. Right now it points to a pdf file, but the user wants to have a message box appear instead.

The code I have is -
<td align="center" width="11%" bgcolor="#C0C0C0"><font color=navy><a href=" HERE</B></a></font></td>

Is this possible?
 
So what happens after the message box appears?? Does the hyperlink still have to work??

Or will the message box contain the path to the document??

Regards,

Patrick
 
The easiest method is probably a simple javascript alert(). Here is one way to do this:

<a href="javascript:alert('This is a popup message box.\nThis is fun!')">Click me</a>

A more elegant method would be to use the javascript window.open method to open a new, small, customized browser window with your own HTML content in it.
 
Try this....

alert(_errMsg);

Code:
<td align="center" width="11%" bgcolor="#C0C0C0"><font color=navy><a href="#" onClick="alert('Message Goes Here');"><B>CLICK HERE</B></a></font></td>
 
Try this....


Code:
<td align="center" width="11%" bgcolor="#C0C0C0"><font color=navy><a href="#" onClick="alert('Message Goes Here');"><B>CLICK HERE</B></a></font></td>
 
Try this....

Code:
<td align="center" width="11%" bgcolor="#C0C0C0"><font color=navy><a href="#" onClick="alert('Message Goes Here');"><B>CLICK HERE</B></a></font></td>
 
Sorry for the multiple replies guys - itchy trigger finger!!!LOL!!!
 
Me Again -

The code worked great.
Here it is - <td align="center" width="11%" bgcolor="#C0C0C0"><font color=navy><a href="#" onClick="alert('TVIS is not operational anymore since the implementation of DELPHI. Travel payments made after 10/23/03 will not be recorded in this system. Going forward, please call your bank to verify that your payment has been made. If you have not been paid or for any other payment related questions, please call the Travel Help Desk at extension 6536.');"><B>CLICK HERE</B></a></font></td>

The message box appears and then the user clicks ok.
Of course now they want more.

When the user clicks ok on the message box they want to be re-directed to a specific web page. can i add all this to the href part of the code?

THANKS
 
Just set the location.href equal to a new location.
Code:
onClick="alert('TVIS is not operational anymore since the implementation of DELPHI.  Travel payments made after 10/23/03 will not be recorded in this system.  Going forward, please call your bank to verify that your payment has been made.  If you have not been paid or for any other payment related questions, please call the Travel Help Desk at extension 6536.');location.href='[URL unfurl="true"]www.newsite.com'"[/URL]
You could also just set up a new javascript function to do the same thing and it would likely look a little neater. It's sometimes more difficult to do several things in a single line as above.
Code:
<script language="javascript">
function doSomething()
{
alert("An error message can go here");
location.href="[URL unfurl="true"]www.SpecificPage.com"[/URL]
}
</script>

<td align="center" width="11%" bgcolor="#C0C0C0"><font color=navy><a href="#" onClick="return doSomething"><B>CLICK HERE</B></a></font></td>
You will probably need to modify these to make sure that everything does what you need, but this should give you an idea.


------------------------------------------------------------------------------------------------------------------------
"The major difference between a thing that might go wrong and a thing that cannot possibly go wrong is that when a thing that cannot possibly go wrong goes wrong it usually turns out to be impossible to get at or repair."
--Dou
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top