Forum Moderators: open

Message Too Old, No Replies

Need a little javascript expertise =)

         

olokiop

10:42 pm on Feb 1, 2005 (gmt 0)

10+ Year Member



First off, here is my script as is.. (doesn't work =[)

<script language=javascript>
if (location.href=mydomain.biz or www.mydomain.biz)
{location.replace("http://www.mydomain.biz/");}
if (location.href=http://www.mydomain.biz/")
{location.replace(unescape(window.location.pathname)"?home=1");}
</script>

Here is what I am trying to accomplish.

If a user enters 'mydomain.biz' into a browser it sends them to 'http://www.mydomain.biz/' before loading anything else.

---logical place to seperate script into two scripts if need be---

upon reaching 'http://www.mydomain.biz/' I want to attach the current path/filename and the text "?home=1" to the end of the url and redirect to the result.

So after any action on the scripts part the user gets 'http://www.mydomain.biz/%file%?home=1' in their address bar and access to the site.

I can think of several ways of doing this in my head but I can't translate any of it into javascript. using non-absolute paths would be greatly apreciated.

Rambo Tribble

3:44 am on Feb 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



= is the assignment operator, == is the comparison operator. Your if statement should be doing a comparison, not an assignment.

Rambo Tribble

5:45 pm on Feb 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Oh, and the "or" operator is ¦¦ (Note that the forum software displays the pipe symbol with a gap in the middle of the vertical line, while your source should display an unbroken vertical bar). Additionally, strings should be enclosed in quotes.

kaled

9:46 pm on Feb 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What you're trying to do is possible. What I can't figure out is why you want to do it.

Perhaps if you explain your thinking, a more elegant solution can be found.

Kaled.