Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi All,

I have two pages
1. default.html
2. login.html

In application startup page is default.html. When run this page will open login.html with separate window(in my case will open the application in full view). At the same time default.html will reopen again and close immediately.

The following source is working fine in ie,chrome, safari. But It is not working in Firefox only.

default.html
<pre lang="xml"><!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>
    <script type="text/javascript">
        function openWin() {
            var qry = window.document.location.href;
            var val = qry.indexOf("flag");
            if (val == -1) {
                window.open("login.html", "Login");
                var selfwin = window.open("default.html?flag=open", "_self");
                selfwin.close();
            }
        }
    </script>
</head>
<body onload="openWin();">
</body>
</html>
</pre>



login.html

<!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>
</head>
<body>
    <form id="frmlogin">
    <h4>
        Login Page</h4>
    </form>
</body>
</html>
Posted
Updated 25-Jun-12 18:20pm
v2
Comments
Shelby Robertson 19-Jun-12 10:20am    
"At the same time default.html will reopen again and close immediately."

Why would you want it to reopen and then close? Why not just close?

1 solution

You wrote:
HTML
var qry = window.document.location.href;

W3schools says
The location object is part of the window object and is accessed through the window.location property.

Note: There is no public standard that applies to the location object, but all major browsers support it.

See their first sentence. You should try
XML
var qry = window.location.href;


Cheers,
Peter
 
Share this answer
 
Comments
P.T.R.K 5-Jul-12 8:22am    
I tried still it will not work in FireFox

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900