IE creates a 404 in JavaScript redirect

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

IE creates a 404 in JavaScript redirect

Post by JAB Creations »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


This script works in conjunction with Hi-Fi and Lo-Fi links (onclick event attributes). It determines if the visitor is in the frame or not, loads the frame, loads the song requested in the music frame, and loads the playlist page they clicked the link on in to the main content frame.

The issue is Internet Explorer.  So I came across a 404 in my access log and saw the referrer, checked it out, and determine it was IE because everything else plays nicely. IE mishandles the script and redirects the visitor too...
/music/home/?track=2.1-07.php&audio=2&playlist=2.1.php

There is no home directory in the music directory, they are both parent directories in my account's root. I have no idea how to scan and remove 'music/' out of location.href...sounds like regex and I stink at regex...if that is what I need?

[syntax="javascript"]var thisurl = self.location;
function mplayer(playlist, track)

{
if (top.location == self.location)
{
//alert (thisurl);
location.href = 'home/?' + 'track=' + track + '&playlist=' + playlist;
//
}
}

feyd | Please use[/syntax]

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
nathanr
Forum Contributor
Posts: 200
Joined: Wed Jun 07, 2006 5:46 pm

Post by nathanr »

relative and absolute urls.. try changing..
location.href = 'home/?'
to
location.href = '/home/?'

Regards, Nathan
Post Reply