Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
Is there a way (I guess through JavaScript? or ASP.NET) to redirect a user to their own home page that is set in their browser, like when they click the Home icon on their toolbar?
Posted

I found a solution. I'll post it for the benefit of anyone searching these forums:

 

<%
   Response.write("<script language=" & Chr(34) & "JavaScript" & Chr(34) & ">" & Chr(13))
   Response.write("<!--" & Chr(13) & "if (document.layers) {" & Chr(13))
   Response.write("    window.home();" & Chr(13) & "} else {" & Chr(13))
   Response.write("    window.location.href=" & Chr(34) & "about:home" & Chr(34) & ";" & Chr(13))
   Response.write("}" & Chr(13) & "//-->" & Chr(13) & "</script>" & Chr(13))
   %>

Posted
Because I really don't know what I am doing yet! :) Also, I thought that ASP.NET won't handle straight JavaScript when it serves up the resulting ASP.NET page in HTML format, so it must be written with Response.Write. Am I wrong?
Posted

Oh I see. The response.write will work, but it would definetly look cleaner if you just added this code to the body of your html. You see this is Client side Javascript, so ASP.NET doesn't even really process it, the browser does. All the response.write is add it to the HTML stream so that the browser gets it. If you view the source you'll see it sitting there (and it should look the same as what I below unless I made a typo)

 

   <script language="JavaScript">
       if (document.layers) {
           window.home();
       } else {
           window.location.href="about :home";
       }
   </script>

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...