dcsimg
www.webdeveloper.com
Page 2 of 2 FirstFirst 12
Results 16 to 23 of 23

Thread: I am trying to make a tab on my website confirm before gonig to the link.

  1. #16
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,591
    Ok, this is My Script in its entirity.

    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    <script>
    function gotoit(o){
    if(confirm("Are you sure?")){
    	o.href="http://google.com";
    	o.target = "blank";
    	}
    }
    
    </script>
    </head>
    
    <body>
    <li><a href="javascript:;" title="blog" target="" onclick="gotoit(this);">Blog</a></li>
    
    </body>
    </html>
    When I click on the blog link, the image here is what I get... blog1.jpg and what I then do is click on cancle and this is what I am left with blog2.jpg so I refresh the page after clicking cancle and then answer OK to the question and I get taken to the page I set which is google.com blog3.jpg

    This has been tested in Chrome, Firefox and Opera. Each browser did exactly as predicted so you must be doing something wrong, I suggest that you review your code or have your system swerpt for malware.

    If you are using MSIE then try a different browser then see if you have any difference in the way the script works.
    If your post falls off the page, bump it. ...
    Please remember to wrap any code you have in forum tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

  2. #17
    Join Date
    Jan 2014
    Posts
    13
    Ok, it works perfect on Firefox, but on IE and iphone and ipad it will work fine if you always click CANCEL, but if you click ok 1 time, the rest of the website will take you to the blog if you click the link, instead of canceling the request.

  3. #18
    Join Date
    Jan 2014
    Posts
    13
    I take that back, it does it on firefox as well. I know you are trying to help me but I really am doing what you told me to do.

  4. #19
    Join Date
    Jan 2014
    Posts
    13
    UPDATE, if after I go there 1 time, and close it. if I refresh the screen, and then click cancel again, IT WORKS, it doesn't take me to the blog, so what do you think that can be? that is confirmed on IE, and firefox..


    to better explain, when I hover over BLOG I see the words in the corner javascript:;
    after I click it and go to OK, the next time I hover over blog, it now shows the URL to the blog website, so if I refresh it, then I will see the word javascript:; and then it works as it should.

  5. #20
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,591
    No idea, are your browsers up to date?

    If the script is not doing what you require, then you will need to have a rethink about why you don't want people to leave your site, perhaps opening a new browser tab and then having the link open up the forum in that new window...
    If your post falls off the page, bump it. ...
    Please remember to wrap any code you have in forum tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

  6. #21
    Join Date
    Jan 2014
    Location
    Calgary, Canada
    Posts
    29
    Nice question.... I also want a tab on my website help us

  7. #22
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,591
    Errmm See above martin183, the answer is given but the person being helped is having issues with implementing something that has been tested and I know it to work which means I can't give anymore help than I already have.
    If your post falls off the page, bump it. ...
    Please remember to wrap any code you have in forum tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

  8. #23
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,591
    Possibly location.replace() http://www.w3schools.com/jsref/met_loc_replace.asp in place of o.href, eg,
    Code:
    function gotoit(o){
    if(confirm("Are you sure?")){
    	location.replace("http://google.com");
    	}
    }
    Reality is it takes a little bit of effort on researching, simple questions in google will often return the answer you need.
    If your post falls off the page, bump it. ...
    Please remember to wrap any code you have in forum tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles