SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Evangelist
    Join Date
    Jun 2004
    Location
    ny
    Posts
    560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    redirect fails -undefined url

    Hi all,
    I need to redirect to a specific page a after form slection butI am gettimg the error of "sPrefHome is undefined" after message is shown.
    Any help is appreciated.

    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=utf-8" /--->
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    
    
    <META Name="keywords" Content="">
     
    <title>Untitled Document</title>
    <link rel="stylesheet" type="text/css" media="all" href="css/dupont_master.css" />
    <script LANGUAGE="JavaScript"> 
    <!--
    function processCountrySelector(_form){
         var bRememberHome = _form.remember.checked;
        var sPrefHome = _form.goUrl.options[document.sendUrl.goUrl.selectedIndex].value;
        var cookieName = "HomeCookie";
        var path = "/";
        var domain = "domain.tr";
        if (bRememberHome){
           var thisDate = new Date();
           thisDate.setYear(9999);
           thisDate.setMonth(0);
           thisDate.setDate(1);
           //alert ("thisDate="+thisDate);
     
           var curCookie = cookieName + "=" + escape(sPrefHome) +
           ((thisDate) ? "; expires=" + thisDate.toGMTString() : "")+
           ((path) ? "; path=" + path : "")+
           ((domain) ? "; domain=" + domain : "");
           //alert ("curCookie="+curCookie);
           document.cookie = curCookie;
          // alert("past this deal" + sPrefHome);
    
       }
    
      //alert(window.location.search);
    	document.write("<br><br><br><br><br><h3 align='center'>loading...please wait</h3>");
    	document.close();
    	setTimeout("window.location.assign(sPrefHome);", 10000);
    
    
    
    
    }
    //-->
    </script>
    </head>
     
    <body>
    <table cellspacing="15" cellpadding="0" border="0" align="center">
    <tr><td></td></tr>
    <tr><td></td></tr>
    <tr><td></td></tr>
    <tr><td><img src="imgs/header.png" /></td></tr>
    </table>
     
    <!--form name="sendUrl" onsubmit="return dropdown(this.gourl)" action="#" method="post"-->
    
    <form name="sendUrl" method="post">
    <table cellspacing="0" cellpadding="0" border="0" align="center">
    <tbody>
    <tr><td>&nbsp;</td></tr>
    <tr><td>&nbsp;</td></tr>
    <tr><td>&nbsp;</td></tr>
    <tr><td>&nbsp;</td></tr>
    <tr>
    <td>
    <div id="countrySelector">
    <div class="selectBox">
    <span class="elementTitle">Bir Ülke (Dil) Seçiniz</span>&#160;
    <select class="dropDown" name="goUrl">
    <!--option value="Select" selected="selected">- Select -</option-->
    <option value="IdentityManager" selected="selected">Türkiye (Türkçe)</option>
    <option value="IdentityManagerEnglish">United States (English)</option>
    
    
     
    </select>
    &#160;<a class="body01link" href="#"><img class="inlineImg" onclick="javascript:processCountrySelector(document.sendUrl);" src="imgs/go_ovr.png" alt="Go" border="0"/></a>
    </div>
    <input type="hidden" value="value" name="remember">
    &#160;
    </div>
    </td>
    </tr>
    </tbody>
    </table>
    </form>
     
    </body>
    </html>

  2. #2
    Grüße aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,358
    Mentioned
    179 Post(s)
    Tagged
    9 Thread(s)
    Hi there,

    Try changing this:

    Code JavaScript:
    setTimeout("window.location.assign(sPrefHome);", 10000);

    to this:

    Code JavaScript:
    setTimeout(function(){
      window.location.assign(sPrefHome);
    }, 1000);

    Does that help?

  3. #3
    SitePoint Evangelist
    Join Date
    Jun 2004
    Location
    ny
    Posts
    560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Pullo View Post
    Hi there,

    Try changing this:

    Code JavaScript:
    setTimeout("window.location.assign(sPrefHome);", 10000);

    to this:

    Code JavaScript:
    setTimeout(function(){
      window.location.assign(sPrefHome);
    }, 1000);

    Does that help?
    Noap, it stays on message page and doesnt redirect.No error though.

  4. #4
    Grüße aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,358
    Mentioned
    179 Post(s)
    Tagged
    9 Thread(s)
    Oh, that's a shame.
    Funnily enough it works just fine for me in the latest Chrome.

    Just to be sure, try this:

    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>
        <!--<link rel="stylesheet" type="text/css" media="all" href="css/dupont_master.css" />-->
      </head>
       
      <body>
        <form name="sendUrl" method="post">
          <div id="countrySelector">
            <div class="selectBox">
              <span class="elementTitle">Bir Ülke (Dil) Seçiniz</span>
              *
              <select class="dropDown" name="goUrl">
                <option value="IdentityManager" selected="selected">Türkiye (Türkçe)</option>
                <option value="IdentityManagerEnglish">United States (English)</option>
              </select>
              *
              <a class="body01link" href="#">
                <img class="inlineImg" onclick="javascript:processCountrySelector(document.sendUrl);" src="imgs/go_ovr.png" alt="Go" border="0"/>
              </a>
            </div>
            <input type="hidden" value="value" name="remember">
            *
          </div>
        </form>
    
        <script type="text/javascript">
          function processCountrySelector(_form){
            var bRememberHome = _form.remember.checked;
            var sPrefHome = _form.goUrl.options[document.sendUrl.goUrl.selectedIndex].value;
            var cookieName = "HomeCookie";
            var path = "/";
            var domain = "domain.tr";
            
            if (bRememberHome){
              var thisDate = new Date();
              thisDate.setYear(9999);
              thisDate.setMonth(0);
              thisDate.setDate(1);
            
              var curCookie = cookieName + "=" + escape(sPrefHome) +
              ((thisDate) ? "; expires=" + thisDate.toGMTString() : "")+
              ((path) ? "; path=" + path : "")+
              ((domain) ? "; domain=" + domain : "");
              document.cookie = curCookie;
            }
            
            document.write("<br><br><br><br><br><h3 align='center'>loading...please wait</h3>");
            document.close();
            setTimeout(function(){
              window.location.assign(sPrefHome)
            }, 500);
          }
        </script>
      </body>
    </html>
    I stripped out a lot of the unnecessary HTML and corrected one or two errors.

    Try saving this to a file on your PC, running it and clicking on the submit image (which should be an input[type="submit"] or a button, BTW).
    What happens?

  5. #5
    SitePoint Evangelist
    Join Date
    Jun 2004
    Location
    ny
    Posts
    560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried as u desc...it stays on the message page without error. Simply it doesnt redirect. I am using ie 8...


    Quote Originally Posted by Pullo View Post
    Oh, that's a shame.
    Funnily enough it works just fine for me in the latest Chrome.

    Just to be sure, try this:

    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>
        <!--<link rel="stylesheet" type="text/css" media="all" href="css/dupont_master.css" />-->
      </head>
       
      <body>
        <form name="sendUrl" method="post">
          <div id="countrySelector">
            <div class="selectBox">
              <span class="elementTitle">Bir Ülke (Dil) Seçiniz</span>
              *
              <select class="dropDown" name="goUrl">
                <option value="IdentityManager" selected="selected">Türkiye (Türkçe)</option>
                <option value="IdentityManagerEnglish">United States (English)</option>
              </select>
              *
              <a class="body01link" href="#">
                <img class="inlineImg" onclick="javascript:processCountrySelector(document.sendUrl);" src="imgs/go_ovr.png" alt="Go" border="0"/>
              </a>
            </div>
            <input type="hidden" value="value" name="remember">
            *
          </div>
        </form>
    
        <script type="text/javascript">
          function processCountrySelector(_form){
            var bRememberHome = _form.remember.checked;
            var sPrefHome = _form.goUrl.options[document.sendUrl.goUrl.selectedIndex].value;
            var cookieName = "HomeCookie";
            var path = "/";
            var domain = "domain.tr";
            
            if (bRememberHome){
              var thisDate = new Date();
              thisDate.setYear(9999);
              thisDate.setMonth(0);
              thisDate.setDate(1);
            
              var curCookie = cookieName + "=" + escape(sPrefHome) +
              ((thisDate) ? "; expires=" + thisDate.toGMTString() : "")+
              ((path) ? "; path=" + path : "")+
              ((domain) ? "; domain=" + domain : "");
              document.cookie = curCookie;
            }
            
            document.write("<br><br><br><br><br><h3 align='center'>loading...please wait</h3>");
            document.close();
            setTimeout(function(){
              window.location.assign(sPrefHome)
            }, 500);
          }
        </script>
      </body>
    </html>
    I stripped out a lot of the unnecessary HTML and corrected one or two errors.

    Try saving this to a file on your PC, running it and clicking on the submit image (which should be an input[type="submit"] or a button, BTW).
    What happens?

  6. #6
    Grüße aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,358
    Mentioned
    179 Post(s)
    Tagged
    9 Thread(s)
    Hi there,

    The problem is your use of document.write.
    Comment out these two lines and things will work as expected:

    Code JavaScript:
    document.write("<br><br><br><br><br><h3 align='center'>loading...please wait</h3>");
    document.close();

    Why document.write is considered bad

    A better alternative

    See also: http://www.sitepoint.com/insert-in-p...documentwrite/

    Hope that helps.
    If you need any help implementing an alternative, just let us know.

  7. #7
    SitePoint Evangelist
    Join Date
    Jun 2004
    Location
    ny
    Posts
    560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Pullo,
    Thank you very much for your help.
    --------------------
    Quote Originally Posted by Pullo View Post
    Hi there,

    The problem is your use of document.write.
    Comment out these two lines and things will work as expected:

    Code JavaScript:
    document.write("<br><br><br><br><br><h3 align='center'>loading...please wait</h3>");
    document.close();

    Why document.write is considered bad

    A better alternative

    See also: http://www.sitepoint.com/insert-in-p...documentwrite/

    Hope that helps.
    If you need any help implementing an alternative, just let us know.

  8. #8
    Grüße aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,358
    Mentioned
    179 Post(s)
    Tagged
    9 Thread(s)
    Hi there,

    Your original reply was asking for help to fix this, so I did.
    I see you've altered this in the meantime, but maybe you can use it anyway:

    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>
        <!--<link rel="stylesheet" type="text/css" media="all" href="css/dupont_master.css" />-->
      </head>
       
      <body>
        <form name="sendUrl" method="post">
          <div id="countrySelector">
            <div class="selectBox">
              <span class="elementTitle">Bir Ülke (Dil) Seçiniz</span>
              *
              <select class="dropDown" name="goUrl">
                <option value="IdentityManager" selected="selected">Türkiye (Türkçe)</option>
                <option value="IdentityManagerEnglish">United States (English)</option>
              </select>
              *
              <a class="body01link" href="#">
                <img class="inlineImg" onclick="javascript:processCountrySelector(document.sendUrl);" src="imgs/go_ovr.png" alt="Go" border="0"/>
              </a>
            </div>
            <input type="hidden" value="value" name="remember">
            *
          </div>
        </form>
        
        <div id="loading"></div>
    
        <script type="text/javascript">
          function processCountrySelector(_form){
            var bRememberHome = _form.remember.checked;
            var sPrefHome = _form.goUrl.options[document.sendUrl.goUrl.selectedIndex].value;
            var cookieName = "HomeCookie";
            var path = "/";
            var domain = "domain.tr";
            
            if (bRememberHome){
              var thisDate = new Date();
              thisDate.setYear(9999);
              thisDate.setMonth(0);
              thisDate.setDate(1);
            
              var curCookie = cookieName + "=" + escape(sPrefHome) +
              ((thisDate) ? "; expires=" + thisDate.toGMTString() : "")+
              ((path) ? "; path=" + path : "")+
              ((domain) ? "; domain=" + domain : "");
              document.cookie = curCookie;
            }
            
            var loadingDiv = document.getElementById("loading"),
                spinner = new Image();
            spinner.src = "http://bradsknutson.com/wp-content/uploads/2013/04/page-loader.gif";
            spinner.width = "25";
            loadingDiv.innerHTML = "Loading";
            loadingDiv.appendChild(spinner);
            setTimeout(function(){
              window.location.assign(sPrefHome)
            }, 10000);
          }
        </script>
      </body>
    </html>
    Only caveat, make sure you have the rights to use the loading gif.
    The site I took this one from claimed it was free to use.

  9. #9
    SitePoint Evangelist
    Join Date
    Jun 2004
    Location
    ny
    Posts
    560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Pullo,

    I tried the code on ie 8, it doesnt work but it work on other version of ie such 9. How would I fix this?
    ----
    Quote Originally Posted by Pullo View Post
    Hi there,

    Your original reply was asking for help to fix this, so I did.
    I see you've altered this in the meantime, but maybe you can use it anyway:

    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>
        <!--<link rel="stylesheet" type="text/css" media="all" href="css/dupont_master.css" />-->
      </head>
       
      <body>
        <form name="sendUrl" method="post">
          <div id="countrySelector">
            <div class="selectBox">
              <span class="elementTitle">Bir Ülke (Dil) Seçiniz</span>
              *
              <select class="dropDown" name="goUrl">
                <option value="IdentityManager" selected="selected">Türkiye (Türkçe)</option>
                <option value="IdentityManagerEnglish">United States (English)</option>
              </select>
              *
              <a class="body01link" href="#">
                <img class="inlineImg" onclick="javascript:processCountrySelector(document.sendUrl);" src="imgs/go_ovr.png" alt="Go" border="0"/>
              </a>
            </div>
            <input type="hidden" value="value" name="remember">
            *
          </div>
        </form>
        
        <div id="loading"></div>
    
        <script type="text/javascript">
          function processCountrySelector(_form){
            var bRememberHome = _form.remember.checked;
            var sPrefHome = _form.goUrl.options[document.sendUrl.goUrl.selectedIndex].value;
            var cookieName = "HomeCookie";
            var path = "/";
            var domain = "domain.tr";
            
            if (bRememberHome){
              var thisDate = new Date();
              thisDate.setYear(9999);
              thisDate.setMonth(0);
              thisDate.setDate(1);
            
              var curCookie = cookieName + "=" + escape(sPrefHome) +
              ((thisDate) ? "; expires=" + thisDate.toGMTString() : "")+
              ((path) ? "; path=" + path : "")+
              ((domain) ? "; domain=" + domain : "");
              document.cookie = curCookie;
            }
            
            var loadingDiv = document.getElementById("loading"),
                spinner = new Image();
            spinner.src = "http://bradsknutson.com/wp-content/uploads/2013/04/page-loader.gif";
            spinner.width = "25";
            loadingDiv.innerHTML = "Loading";
            loadingDiv.appendChild(spinner);
            setTimeout(function(){
              window.location.assign(sPrefHome)
            }, 10000);
          }
        </script>
      </body>
    </html>
    Only caveat, make sure you have the rights to use the loading gif.
    The site I took this one from claimed it was free to use.

  10. #10
    Grüße aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,358
    Mentioned
    179 Post(s)
    Tagged
    9 Thread(s)
    Quote Originally Posted by emmim44 View Post
    I tried the code on ie 8, it doesnt work but it work on other version of ie such 9. How would I fix this?
    Are you sure?
    I tried the code I provided on IE7, IE8, IE9, IE10 and it worked for me on every one.
    Admittedly, the spinner resizing fails, but I would then just do that manually in a graphics program, like Photoshop.

  11. #11
    SitePoint Evangelist
    Join Date
    Jun 2004
    Location
    ny
    Posts
    560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What do you mean by "Admittedly, the spinner resizing fails, but I would then just do that manually in a graphics program, like Photoshop"?

  12. #12
    Grüße aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,358
    Mentioned
    179 Post(s)
    Tagged
    9 Thread(s)
    When testing in IE, this line:

    Code JavaScript:
    spinner.width = "25";

    seems to have no effect and the spinner is displayed at its original size.

    I would therefore resize the spinner image to the size which I wanted it to appear at and remove the above line.


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
  •