SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Nov 2001
    Location
    RI, USA
    Posts
    140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    javascript redirect

    Hi,

    I don't know why this won't work.. It will not redirect to 'theURL'.. I'm requesting the script via a link..

    <A onclick="deleteConfirm('page',null,'mypage.asp?action=delete_page&pageid=471')">delete</A>

    function deleteConfirm(what,formName,theURL) {
    if (confirm("Are you sure?")) {
    if (formName != null) {
    form.submit(formName);
    } else {
    window.location = theURL;
    }
    } else {
    return;
    }
    }
    in1.com | Bootply - Bootstrap playground

  2. #2
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi aspapp,

    it tries to go to the page on my machine. However, you do have problems here, specifically:

    form.submit(formName);

    should probably be:

    document.formName.submit()

    Also, if you are always sending 'null', why are you testing for it?

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still

  3. #3
    SitePoint Zealot
    Join Date
    Nov 2001
    Location
    RI, USA
    Posts
    140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    thanks

    I think I fixed it..

    the problem was I had a href='void(0);' in the link with onclick and it seems that was preventing the location.href from working.. so I made it a button instead.
    in1.com | Bootply - Bootstrap playground

  4. #4
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    <A href="javascript:deleteConfirm('....

    works for me.

    What about the form.submit(formName) ?

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still


Bookmarks

Posting Permissions

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