Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 150811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:20:58+00:00 2026-05-11T09:20:58+00:00

Question: IE and Firefox / Safari seem to deal differently with BASE HREF and

  • 0

Question:

IE and Firefox / Safari seem to deal differently with BASE HREF and Javascript window.location type requests. First, is this an accurate description of the problem? What’s going on? And what’s the best cross-browser solution to deal with this situation?

Context:

I have a small PHP flat file sitelet (it’s actually a usability testing prototype).

I dynamically generate the BASE tag’s HREF value in PHP, i.e. if it’s running on our company’s server, it’s:

$basehref = 'http://www.example.com/alpha/bravo/UsabilityTest/'; 

and on my local dev machine, it’s:

$basehref = 'http://ellen.local/delta/echo/foxtrot/UsabilityTest/';     

For one of the tasks, I collect some user input, do some transformations on it in Javascript, and send to the server using code like this:

function allDone() {     // elided code for simplicity of stackoverflow question     var URI = 'ProcessUserInput.php?';     URI = URI + 'alphakeys=' + encodeURI( keys.join(',') );     URI = URI + '&sortedvalues=' + encodeURI( values.join(',') );     window.location = URI; } 

Both the javascript file (containing function allDone()) and the processing PHP script (ProcessUserInput.php) live in a subdirectory of UsabilityTest. In other words, their actual URL is

http://www.example.com/alpha/bravo/UsabilityTest/foxtrot/ProcessUserInput.php aka

$basehref . '/foxtrot/ProcessUserInput.php'

The Problem

IE’s JavaScript basically seems to ignore the BASE HREF. The javascript and the PHP processor live in the same directory, so the call to ProcessUserInput.php works out fine. The input gets processed and everything works fine.

But when I test on Firefox, the JavaScript does appear to use the BASE HREF, because the script’s output gets sent to

$basehref . '/ProcessUserInput.php' 

This breaks, because ProcessUserInput.php is in a subdirectory of basehref. However, if I add the subdirectory name to the javascript, it no longer works in IE.

Solutions?

I can think of a few ways to solve this:

  • In Javascript, read the HREF property of the BASE tag and manually prepend to var URI in the javascript, calling a fully-resolved absolute URL
  • Process the .js file with PHP and insert the $basehref variable into the script
  • Move the files around
  • Something else?

I’m sure there must be other ways to solve this too. What’s the best way to deal with BASE HREF in JavaScript when IE and Firefox apply it differently in JavaScript?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T09:20:59+00:00Added an answer on May 11, 2026 at 9:20 am

    Using the assign method of window.location seems like the most straightforward answer.

    Instead of

    window.location = URI; 

    I’m using this:

    window.location.assign( URI );  

    which is doing the right thing in both IE and Firefox.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This might seem like a really dumb question, but I am writing an application
This may not seem like a development question but there is a link. I
First of all, I don't believe my question is a duplicate of this .
I'm seeing this issue in Internet Explorer 8, but not in Safari or Firefox.
The Question: How do I install multiple Firefox extensions into a fresh Firefox v11+
I have a question about the behavior of a browser( especially Firefox ) tackling
I've got a pretty straight forward question regarding viewing text in Firefox. My application
I am writing my first FireFox extension and I have some questions. Maybe someone
Question from Object-Oriented JavaScript book: Imagine Array() doesn't exist and the array literal notation
I am using the following test. In firefox/chrome/safari on my mac, panel1 renders above

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.