Click to See Complete Forum and Search --> : message box
bvinson
07-21-2003, 09:56 AM
I couldn't find this in the FAQ - sorry. I have a .js footer that works well. I need, however, to be able to have a message box popup on a link click. Then, after the user clicks "OK" in the message box, the intended url will appear. (Not a new popup window). Here is what I have, but not sure where or how to include it in my main page or my .js footer file. Also, once this code (your answer) is on the main page, would this same additional code be required on each page that includes the .js footer? I hope this makes sense.
// email privacy advisory
function Advisory (URL) {
msg =("By sending us an electronic mail message (for example, an e-mail message addressed to the webmaster), you may be sending us personally-identifying information. In these cases, we may retain the information as long as necessary to respond to your request or otherwise resolve the subject matter of your e-mail. Please be aware that email is not necessarily secure from interception or misdirection. For your own protection you may wish to communicate sensitive information using a method other than email." );
if (confirm(msg))
location.href=URL;
else
location.href='javascript:void(0)';
}
// Sample url to use with the Advisory function
<a href="javascript:Advisory('mailto:webmaster@netwarcom.navy.mil');" accesskey="m" title="Email Webmaster">Webmaster</a>
cacalex
07-21-2003, 11:11 AM
Try this :
Choice = confirm(msg);
if(Choice=="1") //If OK is press...
{
location.href=URL;
}
else
{
}
bvinson
07-21-2003, 11:27 AM
OK, but that doesn't tell me where to put it. Part of my question is: does it go in the body of each page where the .js footer is? Or does it go in the .jf footer? Here's my footer which is included on each page: Where do I put what you gave me?
<!-- Begin
document.write('<hr size="2" hr color="#00009C">');
document.write('<center>');
document.write('<font face="arial" font size="2"><a
href="http://forcenet.navy.mil/Fn_privacy.htm"> Privacy & Security Notice </a> ');
document.write('<a style="padding: 2px 60px 2px 30px"><a
href="mailto:beth.vinson@netwarcom.navy.mil"> FORCEnet Content Manager</a> ');
document.write('<a style="padding: 2px 60px 2px 30px"><a
href="http://www.chinfo.navy.mil/navpalib/accessibility/"> Accessibility </a> ');
document.write('</center>');
document.write('<br>');
// End -->
cacalex
07-21-2003, 11:32 AM
I guss the best thing to do is to put the code in a JS file, and then, call this file from all of your pages...
bvinson
07-21-2003, 11:44 AM
Let me try this once more. Apparently I don't understand all I know about this :)
1 - on a standard page, I call a footer.js file.
(This is the file content):
<!-- Begin
document.write('<hr size="2" hr color="#00009C">');
document.write('<center>');
document.write('<font face="arial" font size="2"><a
href="http://forcenet.navy.mil/Fn_privacy.htm"> Privacy & Security Notice </a> ');
document.write('<a style="padding: 2px 60px 2px 30px"><a
href="mailto:beth.vinson@netwarcom.navy.mil"> FORCEnet Content Manager</a> ');
document.write('<a style="padding: 2px 60px 2px 30px"><a
href="http://www.chinfo.navy.mil/navpalib/accessibility/"> Accessibility </a> ');
document.write('</center>');
document.write('<br>');
// End -->
2 - I call the above file by putting this in the body:
<script="Javascript1.2" src="footer.js"></script>
3 - Within that .js file, I need to have a message box appear when a link is clicked, and then when the user clicks "OK" in the message box, they receive the intended URL.
How do I make this happen?
cacalex
07-21-2003, 01:30 PM
<!-- Begin
document.write('<hr size="2" hr color="#00009C">');
document.write('<center>');
//Notice the href="#" Link... And onClick...
document.write('<font face="arial" font size="2"><a href="#" onclick="LinkClick1();"> Privacy & Security Notice </a> ');
document.write('<a style="padding: 2px 60px 2px 30px"><a href="mailto:beth.vinson@netwarcom.navy.mil"> FORCEnet Content Manager</a> ');
document.write('<a style="padding: 2px 60px 2px 30px"><a href="http://www.chinfo.navy.mil/navpalib/accessibility/"> Accessibility </a> ');
document.write('</center>');
document.write('<br>');
// End -->
//And there's our little message box...
function LinkClick1() {
var msg="Are you sure ?";
Choice = confirm(msg);
if(Choice=="1") //If OK is press...
{
location.href="http://forcenet.navy.mil/Fn_privacy.htm";
}
else
{
//Just do nothing...
}
}
Does it help a little ???
bvinson
07-21-2003, 01:36 PM
Yes, thank you for your patience and help!
cacalex
07-21-2003, 01:52 PM
If it help you, i'm happy...:cool: