<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-9197301729422218768</id><updated>2012-02-16T03:04:54.471-08:00</updated><title type='text'>How to Use the Javascript Confirm Function</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://javascriptconfirmfunction.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9197301729422218768/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://javascriptconfirmfunction.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Mike Jones</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>1</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-9197301729422218768.post-2532845543939255041</id><published>2009-02-20T07:13:00.001-08:00</published><updated>2009-02-20T07:13:11.639-08:00</updated><title type='text'></title><content type='html'>&lt;a href="http://www.wikihow.com/Main-Page"&gt;&lt;img src="http://www.wikihow.com/skins/WikiHow/wikiHow.gif" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;h1 style="margin-bottom: 0px;"&gt;&lt;a href="http://www.wikihow.com/Use-the-Javascript-Confirm-Function"&gt;How to Use the Javascript Confirm Function&lt;/a&gt;&lt;/h1&gt;&lt;br /&gt;&lt;b&gt;&lt;i&gt;from &lt;a href="http://www.wikihow.com/Main-Page"&gt;wikiHow - The How to Manual That You Can Edit&lt;/a&gt;&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Have you ever needed to make the user confirm something? Ever wanted the user to click OK and be redirected to a site and click Cancel to stay on the current page? Read on and find out a very simple way to do so with the JavaScript &lt;i&gt;confirm();&lt;/i&gt; function.&lt;br /&gt;&lt;a name="Steps"&gt;&lt;/a&gt;&lt;h2&gt;  Steps &lt;/h2&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Create a variable and initialize its value to the return value of the confirm() function.&lt;br /&gt;var userChoice = confirm("Do you want to leave WikiHow?");&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Use a set of &lt;i&gt;if&lt;/i&gt; statements or &lt;a href="http://www.wikihow.com/Create-Javascript-Conditional-Operators" class="external text" title="http://www.wikihow.com/Create-Javascript-Conditional-Operators" rel="nofollow"&gt;conditional operators&lt;/a&gt; to determine the effect of clicking OK or Cancel. When the user clicks OK, confirm() returns the value &lt;i&gt;true&lt;/i&gt;. If&lt;br /&gt;userChoice ? (alert("Aw, bye!");window.location="http://www.google.com/") :&lt;br /&gt;alert("Alright! Thanks for sticking around.");&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;&lt;a name="Tips"&gt;&lt;/a&gt;&lt;h2&gt;  Tips &lt;/h2&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;The confirm() function can be used directly within HTML as an event. For example: &lt;i&gt;&lt;/i&gt;&lt;form onsubmit="'confirm("&gt;&lt;i&gt;&lt;/i&gt; or &lt;i&gt;&lt;/i&gt; If the user clicks Ok, the event will go forward, if not, it won't. It's that simple.&lt;br /&gt;&lt;/form&gt;&lt;/li&gt;&lt;li&gt;Using conditional operators is faster than using &lt;i&gt;if&lt;/i&gt; statements, but it may look confusing.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;You can use the confirm() function for anything including preventing underage users from entering your site.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;a name="Related_wikiHows"&gt;&lt;/a&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9197301729422218768-2532845543939255041?l=javascriptconfirmfunction.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javascriptconfirmfunction.blogspot.com/feeds/2532845543939255041/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javascriptconfirmfunction.blogspot.com/2009/02/how-to-use-javascript-confirm-function.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9197301729422218768/posts/default/2532845543939255041'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9197301729422218768/posts/default/2532845543939255041'/><link rel='alternate' type='text/html' href='http://javascriptconfirmfunction.blogspot.com/2009/02/how-to-use-javascript-confirm-function.html' title=''/><author><name>Mike Jones</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
