Click to See Complete Forum and Search --> : Message box (newbie)
brendanh
07-22-2003, 08:16 PM
Using the following code:-
Do you surf the <a href='javascript:alert("The World Wide Web is .....");'>World Wide Web</a>?
Result is a message box with ALERT symbol. My target audience enters panic mode when they see this symbol.
Can anybody point me to or suggest an alternative to alert/another alternative altogether. Box is linked to highlighted text in a web page.
Regards,
Brendan.
What is it that you need to do? I don't see any use for your example...
brendanh
07-23-2003, 01:31 AM
Sorry if my request was vague.
The example shows the following on screen (in a html page):-
'Do you surf the World Wide Web ?'
The 'World Wide Web' is highlighted text that the user can click.
On specific webpages I would like to have text highlighted as 'keywords', and if the user were to click on the highlighted text they would get a message box popup of text describing the keyword. I have no probelm with the message box used in the code example, just the alert symbol.
I know I could just make another html page linking to that text but the site will have 80+ odd keywords.
Regards,
Brendan
Exuro
07-23-2003, 01:42 AM
Okay, here are a couple solutions. The first I thought of was to use VBScript:
<script type="text/vbscript">
<!--
msgbox "World Wide Web",0
-->
</script>
But, since that's VBScript it's IE-Only. The second option is to use a Confirm box instead of an Alert. This means that there will be an Ok/Cancel instead of just an ok.
<a href="#" onclick="JavaScript:confirm('The World Wide Web is...');">WWW</a>
Edit: That code is wrong. The correct code is in a later post. Sorry.
I changed your code form the form where the javascript was being called from the href attribute to this because it was actually changing the page to a document that just said "true" in Mozilla... Well, hope that helps!
brendanh
07-23-2003, 01:59 AM
Thanks EXURO, but it does not seem to work.
I cut/pasted your exact code into the web page (exact as you posted it but without the 'code' tags) and viewed it and the WWW is highlighted but clicking on it reveals nothing, no message box, no error.
Also thanks for the VB script, but my aim is to keep the site simple 'and' cross-browser compatible.
I tried your 'confirm' in the original post and code I made and it actually works well, with an OK and a CANCEL. Problem is that if you click on OK it tries to go to another webpage.
Exuro
07-23-2003, 02:27 AM
oh wow, I really butchered that. It was supposed to be:
<a href="#" onclick="confirm('The World Wide Web is...');">WWW</a>
You may also want to try the code I attached... It's a little DHTML popup thing that makes a little division pop up when the user clicks a keyword on the page... Sorry about the bad code before :(... Hope this helps though!
brendanh
07-23-2003, 04:22 AM
Exuro, you hit the ni\ail right on the head.
Your msgbox.txt file is exactly what I have been loking for. looks good, easy to use and no ALERT or QUESTION MARKS.
Only question is, can I make it centre on the screen. In Mozilla Firebird, Galeon and IE they all display it in the top RH corner (I can actualy live very hapilly with this but thought I would ask anyway.
Again, many thanks to you.
Regards,
Brendan
No, you can't change the postition of the confirm box, though for me, it is centered...
Exuro
07-23-2003, 06:49 PM
I don't think pyro read the reply... The position of the division is defined here:
#popup {position:absolute;top:10px;right:10px;border: 2px ridge gray;padding:5px;
background-color:white;text-align:center;visibility:hidden;z-index:2;}
And Here:
document.getElementById('popup').style.top=document.body.scrollTop+10
You can mess around with those values to change the position of the division. You can also swap the word "left" in for "right" to make it the distance from the left side of the screen instead of the right. "top:10px;right:10px;" places the popup 10 pixes from the top and right of the screen. The "+10" in the JavaScript places it 10 pixels from the "scrollTop" of the screen. You can also try putting <center></center> around the division if you want, but I don't think that looks too great...
brendanh
07-23-2003, 08:14 PM
Thanks for that.
I changed the scrollTop to 200 which looks pretty good.
Maybe a subsequent question ?. Is it possible to make lines of 'description' text on seperate lines. In the html code I have to type the 'description' in 1 long line. Because of the length of the 'description' this ends up being about 4 pages wide in the code but displays at the browser width. Although it works and 'bluefish' does not complain it is a bit hard to work with.
Other than that, I tank you very much for your assistance. This message box is very helpful to my website and customers.
Regards,
Brendan
Originally posted by Exuro
I don't think pyro read the reply...You're right, my bad... I just skimmed it and thought they were still asking about a confirm box...
Exuro
07-24-2003, 12:32 AM
If you want the description on more than one line, just toss in a <BR> tag. In fact, you can put any HTML you want in there! You could also specify a width in the CSS for the division. Just throw in something like "width:250px;" after the top & left properties and it should wrap by itself.