JavaScript - Small Tips II (How To Make An Alert Message Pop Up Box)
>> Friday, April 30, 2010
Before we go any further to discuss this JavaScript - Small Tips II, I must remain you as in JavaScript I, that at least there are 2 think we must be consider to use the JavaScript apps , because to many JavaScript in your template will slowing down your web page to load. Besides that, for security reason, many user set their browser to disable JavaScripts. To resolve these problem, we must be wise to choose which the JavaScript that will be install into our template (choose the appropriate and useful JS apps) and use the "warning message" that we using JavaScript .
How To Make An Alert Message With JavaScript.
The functions of an alert message is to provide announcements, information or warning to the guests before they go to see or read the entire contents of our site.
There are a few display an alert message that we can create, an alert message box which only has a button 'OK', "OK" button and "cancel" to divert to other sites, and an alert message box with a dialog box.
Note: This tricks maybe annoying to some people, because this pop up box will STOP our browsing activity, we will not be able to do anything until we execute this pop up box (click OK or X).
An Alert Message Box With 'OK" Button.
We usually seen this message on "adult" or "serious" sites, the messages give warning to their visitor about the content of the sites and their restriction or limitation.
To create an alert message box, login to your account, go to Template -> Page Elements -> Add a Page Element in your left sidebar or post body area, and select HTML/JavaScript. And paste this code shown below.
<script type="text/javascript">Just change the Red words with your message..!, this words will be displayed as a pop up alert box when the visitors view your site / blog. The Purple words will show up when our guests disable their Javascript on their browser.
alert('You are about to enter our "serious" site. This site contains violence and sadistic material, persons under 18 years old are prohibited ... Beware!')
</script>
<noscript>Enable javascript in your browser to view an important message.</noscript>
Look at this example below..
I put this "alert message" page element right under my header. This alert message box just for an information cause both choices, click "OK" button or click "X" will bring our visitor directly into our site (continuing to open our site).
An Alert Message Box With Confirmation ( "OK" and "Cancel" ) Button.
For any reasons, sometimes we need to give our guests a choice not to continuing or cancel to visiting our website / blog. If our guests prefer to cancel, then they will be redirect into another URL address.
So if we want to do this trick, go to Template -> Page Elements -> Add a Page Element in your left sidebar or post body area or even below your header, and select HTML/JavaScript and Paste this code below.
<script type="text/javascript">Change the Red words with your message..!, the Blue URL is the URL destination address when our guests click the "OK" button, and the Purple URL is the URL destination address when our guests click the "cancel" button or click "X".
confirm('This site contains sadistic materials. Are you sure you want to continue?');
if (confirm('This site contains sadistic materials. Are you sure you want to continue?')) {
window.location = "http://doit2us.blogspot.com/";
}
else {
window.location = "http://www.google.com/";
}
</script>
An Alert Message Box With Dialog Form
Besides give a warning or information to our guest, with this simple Javascript trick below, we can build a warning or information message + dialog form. In this example below, This trick is to give a warning to our guest, knowing the name, and give a welcome message. It,s a rather weird isn't it, but this just a sample, you can created better than this, I just want to share an Idea...
First Script
<script type="text/javascript">The way what we done it, is the same with both How To Make An Alert Message With JavaScript. above, I put the FirstScript page element below my header. Because this is a dialog box, of course we must have a follow up, to continuing the action, So I put a second script in top of my post body as my welcome message.
alert('You are about to enter our "serious" site. This site contains violence and sadistic material, persons under 18 years old are prohibited ... Beware!')
var yourName = prompt("Please, write your name first...!", "Reader");
</script>
<noscript>Enable javascript in your browser to view an important message.</noscript>
<script type="text/javascript"></script>
Second Script
Thank you <script type="text/javascript">document.write(yourName)</script>! Feel free to look around. If you like what you read, please mention us in your post or link to this site. Enjoy your visit <script type="text/javascript">document.write(yourName)</script>So this is what we got with those trick.
When first opened our site or blog, there will be a pop up box warning message just like the first trick,
after click "OK" or "X" button, there will be shown another pop up dialog box like this,
If the Guest write their name into the dialog box (eg. Mc4tur) and click "OK", then they will be brought to continuing opened our site with a welcome message in the place where we put the second script page element.
Well that's all, you can combined those tricks or make a modification (eg. put into the post). but please remember choose wisely because of the disadvantage of the JS tricks.
49 comments:
Thanks for admin.
Very nice.
Thank you for nice tips!is it possible to create meta tags and meta description for blogger? its important thing for SEO
@Tutorijali,
Hi Tutorijali.. yes, Sure it is possible to create meta tags and meta description for blogger, and I have done for this blog too.
A bit complicated, but very good information.
best
I admire the valuable information you offer in your articles. I will bookmark your blog and have my friends check up here often. I am quite sure they will learn lots of new stuff here than anybody else!
When I created the Alert Message with the OK button, I did all the HTML and when I checked my Blog, no message popped up on the screen. What am I doing wrong?
Social media is a great way to increase traffic. But like other ways, you have to know before what you do. That is to say, you have to know your target, your objectives and how to reach them.
I am looking new blogs for new This Is A Sample Of Sticky Post tips and hints and services I Saw This comment on this blog.
This web site is really a walk-through for all of the info you wanted about this and didn’t know who to ask. Glimpse here, and you’ll definitely discover it.
great post! Thanks for sharing such a good information, Brilliant concept to encourage bicycling! linking is very useful thing you have really helped lots of people who visit this blog and provided them this usefull information.
Nice information, many thanks ............! the usefulness and significance is overwhelming. Thanks again and good luck!.
Progressive jave tips! Thanks a lot!
I was wondering if you can have the warning alert come up for only the main home page instead of showing up every time you view posts in the archive? I put one on mine and found it annoying (but funny) because I kept having to hit 'ok'- or maybe a check box for the option don't show me this again while they are on for that session? just a thought- don't know if that is possible.
I actually came onto your website and read just a few information. I like your kind freelance writing and that i need to return there over again definitely but truly.
Nice information really helpful share. I also want to try this one. I really appreciate your effort in sharing this information to us.
Pretty impressed by the quality of material on the website. You have a lot of good resources here. I know I will visit this blog often.iPad Developer
That's a great point to bring up. I offer the thoughts above as general inspiration.
thank you so very much!
This is a very appreciable post I and other people also like your post I appreciate your work which you done keep doing hard working for your bright future.
Its a great opportunity.. Thank you.
Excellent article. Great point to bring this up..
It’s a very nice post of you . you doing a good job keep it up its very beneficial for us and it’s a latest information for us
Nice and informative article about how to create meta tag on blogger,Thanks for giving this important blog.
I do welcome your treasured thought. I am enchanted to know your valued intelligence. For more information I will be in touch.
This was a conviction be told great read, thanks for captivating the time to put it together! Touched on some very good...
This is not necessarily a must-do, and neither is it a best practice, but it could come in handy at times. Thanks for giving this important blog.
I actually came onto your website and read just a few information. I like your kind freelance writing and that i need to return there over again definitely but truly.
This is a very useful website and I have found good information here and I really appreciate the efforts of the writer of this essay for sharing nice ideas. Thanks!
Interface Talent
Thanks a lot for that a fantastically amazing post!
There are undoubtedly a great deal of particulars like that to take into consideration. Each one is very good pints to take into consideration with regard to. I now consider the feelings above because standard ideas.
Best Coffee Maker 2012
I really love to read this post and I am glad to find your distinguished way of writing the post. It shares some very useful points. Thanks and Regards.
That of a wonderful post it is been recently. Thanks for you and expect much more quantity of blogposts such as these. Thank you very much.
mayonnaise cake
I wanted to thank you for this great read article! I definitely enjoyed every little bit of it.
Thanks
It's such an honor to offer the opportunity to sign up for the debate of this excellent web log! I wish to prolong my thank you for this kind of.
This is a great post! I like this topic. This site has lots of advantage! I found many interesting things from this site. It helps me in many ways. Thanks for posting this again.
If you want to start to see the mind-blowing article together with real facts and statistics, it is really huge has an effect on upon viewers and i also admire your writing ability of the publisher.
Thank you for giving people so excellent post. We'll your site help constantly.
Even if you shared or posted a small post here,the quality of the article is really good. I may say thank you so much for this tips.
I will look forward to this page for more reading valuable content in the future. Thank you for sharing this blog post!
Totally, the article is really the greatest on that valuable subject matter. I fit in with your conclusions and certainly are going to thirstily expect your following updates. Just saying thanks are able to not merely be enough, for the amazing quality in your writing.
I like your website, Excellent efforts. i find unique content here.
onion fonts
I am visited many other blog site and read attentively your each post. Afrer reading your post i could understand that the content is most simple and great. Thank you for your great share. Also this is my 1st visit at your site and after visiting your site i enjoyed.
Great amazing things here. I¡¦m very satisfied to look your article. Thanks so much and i am looking forward to contact you.
Roof Contractors
I am really appreciate this wonderful post that you have provided for us. I assure this would be beneficial for most of the people.
Hi, Really great effort. Everyone must read this article. Thanks for sharing.
SWTGROUPINDIA is a Online Marketing, SMO, SEO, Web Design & Development Company in Delhi India. We’re not presenting you an web development and website design, we’re presenting a chance to be a part of the digital marketing company in India.
http://www.swtgroupindia.in/digital-marketing.html
SWTGROUPINDIA is a Online Marketing, SMO, SEO, Web Design & Development Company in Delhi India. We’re not presenting you an web development and website design, we’re presenting a chance to be a part of the digital marketing company in India.
http://www.swtgroupindia.in/digital-marketing.html
Post a Comment