Hi all,
I need help making an alert box like this:
that pops up when you click a link,and when you click the "ok" button it takes you to the links destination and when you click cancel nothing happens.
Does anyone know how to do this?
Hi all,
I need help making an alert box like this:
that pops up when you click a link,and when you click the "ok" button it takes you to the links destination and when you click cancel nothing happens.
Does anyone know how to do this?
Well, it depends upon what you want to have happen if javascript is disabled. In this version, with javascript disabled, it will act as a normal link:
With javascript enabled, it will behave just as you asked it to. If the game cannot be used and played without javascript, this is probably the best method. However, if javascript would be required at the destination but not on the originating page or confirmation is required for legal or other reasons, you could do this:Code:<a href="http://www.google.com/" onclick="return confirm('Do You Really Want to go to Google?');">Google</a>
Code:<a href="javascript:void(0);" onclick="theVar=confirm('Do You Really Want to go to Google?');setTimeout('if(theVar){window.location=\'http://www.google.com/\'}', 0);">Google</a><br> <noscript>Javascript Enabled required for above link</noscript>
Last edited by jscheuer1; 07-21-2006 at 04:15 AM.
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
How to change this so that, when you click OK, it initiates an action? (click on delete icon, press OK and it calls the javascript to delete the row) i have the script to delete a row.. how should i call a js function within this confirm syntax?
Generally, you can just put it in the flow of the delete function. Something like:
Code:function delete(){ do some prep stuff here if you like var answer=confirm('Do you Really want to do this?') if (answer) { do the thing here } do some clean up stuff here if needed }
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
thanks jscheuer1
Thanks jscheuer1, that would work except I'm using dynamic drives Fold-out external menu and it dissapears whenever I have an onclick attribute on this link. Here ill post some code so you can see what I'm dealing with here, its php.
I also tried adding code for the onclick event like this:PHP Code:<td valign="top"><div align="center">
<?php
for ($i=0; $i <= count($arraymember)-1; $i++){
echo("<a href=\"?world=" . $arraymember[$i] . "&detail=" . $detailq . "\" class=\"world\" target=game >World " . $arraymember[$i] . "</a></ br>");
}
?>
</div></td>
And then using . $onclick . to call it but it didnt like it and it hid the foldout menu.PHP Code:$onclick = "onclick="return confirm('Do You Really Want to go to Google?');""
Anymore ideas?
Heres where its being used:
http://runecore.selfip.com:82/switch/switchindex.php
and heres the link to the menu file:
http://runecore.selfip.com:82/switch/menu.php
can be summed up as:Code:<?php for ($i=0; $i <= count($arraymember)-1; $i++){ echo("<a href=\"?world=" . $arraymember[$i] . "&detail=" . $detailq . "\" class=\"world\" target=game >World " . $arraymember[$i] . "</a></ br>"); } ?>Code:<?php for ($i=0; $i < count($arraymember); $i++) echo( '<a ' . 'href="?world=' . $arraymember[$i] . '&detail=' . $detailq . '" ' . 'class="world" ' . 'target="game" ' . 'onclick="return window.confirm(\'Do You Really Want to go to Google?\');"' . '>' . 'World ' . $arraymember[$i] . '</a>' . '<br>' ); ?>
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
It works this way! Thank you Twey, what was differnet that made it work?
Most important one was the proper escaping of the quotesI tidied up the HTML somewhat too, though.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
you mean by using single quotes ' instead of double quotes " ?
Bookmarks