alert messages

Discussion in 'HTML & Website Design' started by blaz1988, Oct 5, 2008.

  1. #1
    Nice script in the form of alert messages

    Just add this code in <body> tag:

    <script>
    if (!confirm("Do you want to enter this site?"))
    window.location=history.go(-1)
    </script>

    [​IMG]


    you can change message like this

    <script>
    if (!confirm("Welcome to my UFC blog. There you can find latest UFC and Pride match clips, highlights,news ,fighters profiles,octagon girls and many more. Click OK to enter "))
    window.location=history.go(-1)
    </script>

    [​IMG]
     
    blaz1988, Oct 5, 2008 IP
  2. marcho.usa

    marcho.usa Peon

    Messages:
    51
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    This is a interesting script... :) I will probably find a use for it thanks !
     
    marcho.usa, Oct 5, 2008 IP
  3. I-G4L

    I-G4L Peon

    Messages:
    312
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Do you happen to have the "Are you sure you want to leave this site?" message?

    Thanks for sharing this, I've been looking around for one :)
     
    I-G4L, Oct 5, 2008 IP
  4. Jaguarjace

    Jaguarjace Guest

    Messages:
    52
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    This is the javascript i use to make an alert when somone clicks a link or exit the page:
    <html>
    <head>
    <script>
    function goodbye() { alert('I see you are leaving the site\n\nPlease come back soon!'); }
    </script>
    </head>
    <body onunload ="javascript:goodbye();">
    <a href="http://www.google.com/">Click here to show a goodbye alert</a>
    </body>
    </html>

    Clicking the link shows the message before you leave.
     
    Jaguarjace, Oct 5, 2008 IP
  5. blaz1988

    blaz1988 Active Member

    Messages:
    82
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    93
    #5
    Thanks for sharing this
     
    blaz1988, Oct 6, 2008 IP
  6. blaz1988

    blaz1988 Active Member

    Messages:
    82
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    93
    #6
    Here's another. This script disable right click

    <script language=JavaScript>
    var message="";
    function clickIE() {if (document.all) {(message);return false;}}
    function clickNS(e) {if
    (document.layers||(document.getElementById&&!document.all)) {
    if (e.which==2||e.which==3) {(message);return false;}}}
    if (document.layers)
    {document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
    else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}

    document.oncontextmenu=new Function("return false")
    // -->
    </script>
     
    blaz1988, Oct 6, 2008 IP
  7. blaz1988

    blaz1988 Active Member

    Messages:
    82
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    93
    #7
    In var message=""; , you can write your message , for example var message="No, No! This content is protected";
     
    blaz1988, Oct 6, 2008 IP
  8. hirecontentwriters

    hirecontentwriters Peon

    Messages:
    136
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #8
    ah thanks .. I was looking for the "disable right click" script for one of my friend.
     
    hirecontentwriters, Oct 6, 2008 IP
  9. steelfrog

    steelfrog Peon

    Messages:
    537
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Ugh. I hate receiving those pop-up messages. Also, keep in mind that disabling right-click is horrible for people who like to open links in new windows and will in no way prevent the user from seeing your source code. Alienating your users is a good way to lose traffic.
     
    steelfrog, Oct 6, 2008 IP
  10. Dodger

    Dodger Peon

    Messages:
    1,494
    Likes Received:
    60
    Best Answers:
    0
    Trophy Points:
    0
    #10
    So do I. That is why I use the NoScript extension for Firefox. If I want to leave a site, there is a reason for it and having me click on an alert box will guarantee that you will never see me again.

    As for the right click menu item to open in new window, I like my middle-button click which opens in a new tab. I think I have about worn out that button. :D
     
    Dodger, Oct 6, 2008 IP
  11. steelfrog

    steelfrog Peon

    Messages:
    537
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Agreed. Rarely do I not open a window in a tab anymore, but many IE users still use the old right-click, open in new window routine and few know about the shift-key shortcut.
     
    steelfrog, Oct 6, 2008 IP
  12. Dodger

    Dodger Peon

    Messages:
    1,494
    Likes Received:
    60
    Best Answers:
    0
    Trophy Points:
    0
    #12
    @steelfrog - disabling the right-click was used to deter nosy competitors from doing certain functions when they were visiting your site. It was only a nuisance then, and people were pretty savvy and got around it anyway. Now it is basically a useless script with the tools we have available today.

    As for the new window thing in IE, doesn't the middle-button work there too? Of course, you are probably right about most people not even knowing about that either.
     
    Dodger, Oct 6, 2008 IP
  13. steelfrog

    steelfrog Peon

    Messages:
    537
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #13
    It doesn't work in IE6 at least; I'm assuming IE7 has the same middle-click behavior as Firefox.
     
    steelfrog, Oct 6, 2008 IP
  14. blaz1988

    blaz1988 Active Member

    Messages:
    82
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    93
    #14
    Disable picture copy.

    <script language="JavaScript1.2">


    var clickmessage="insert you text"

    function disableclick(e) {
    if (document.all) {
    if (event.button==2||event.button==3) {
    if (event.srcElement.tagName=="IMG"){
    alert(clickmessage);
    return false;
    }
    }
    }
    else if (document.layers) {
    if (e.which == 3) {
    alert(clickmessage);
    return false;
    }
    }
    else if (document.getElementById){
    if (e.which==3&&e.target.tagName=="IMG"){
    alert(clickmessage)
    return false
    }
    }
    }

    function associateimages(){
    for(i=0;i<document.images.length;i++)
    document.images.onmousedown=disableclick;
    }

    if (document.all)
    document.onmousedown=disableclick
    else if (document.getElementById)
    document.onmouseup=disableclick
    else if (document.layers)
    associateimages()
    </script>
     
    blaz1988, Oct 6, 2008 IP
  15. marcho.usa

    marcho.usa Peon

    Messages:
    51
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #15
    Who uses right-click open in new window. In Firefox I just click the scroll button and open the link in a new tab :)
     
    marcho.usa, Oct 6, 2008 IP
  16. Project Mobius

    Project Mobius Peon

    Messages:
    10,524
    Likes Received:
    170
    Best Answers:
    0
    Trophy Points:
    0
    #16
    hmmmm I use both open in new window and new tab, for all browsers

    And the js alert box is so 90s, I will never return after the initial visit to a site with this script
     
    Project Mobius, Oct 6, 2008 IP
  17. marcho.usa

    marcho.usa Peon

    Messages:
    51
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #17
    yeah thats true about how you might not want to return after you see that box, but I believe that if used properly it can be a good thing, but if you just use it as a welcome message or a "are you sure you wanna leave message" it can be very bad for returning visitors. So it all depends on how you use it.
     
    marcho.usa, Oct 6, 2008 IP
  18. Dodger

    Dodger Peon

    Messages:
    1,494
    Likes Received:
    60
    Best Answers:
    0
    Trophy Points:
    0
    #18
    Ticker marquee in your Title Bar or Status Bar too. They are irritating as all hell.
     
    Dodger, Oct 6, 2008 IP