Click here to Skip to main content
16,017,986 members
Please Sign up or sign in to vote.
1.67/5 (2 votes)
See more:
Hi,

This code is working fine as it close the current window and open software in new window With IE but not working with Chrome


XML
<html>
<head>
<title>Contentverse Online</title>
</head>
<script>
function closeCurrentWindow() {
            var version=0;
            if (navigator.appVersion.indexOf("MSIE")!=-1){
                        var temp=navigator.appVersion.split("MSIE");
                        version=parseFloat(temp[1]);
            }
            if (version>=5.5 && version<=6) {
                        this.focus();
                        self.opener = this;
                        self.close();
            } else {
                        window.open('','_parent','');
                        window.close();
            }
}
</script>
<body>
<script>

window.open("Sign.asp?Home=C:/Program Files/ViewWise Online&VWOFlavor=Full","myWindow",'top=0,left=0,width='+screen.width+',height='+screen.height+',status=yes,resizable=no,scrollbars=yes');
closeCurrentWindow();
</script>
</body>
</html>
Posted
Comments
VICK 5-Nov-13 2:24am    
Why dont you try .replace method to simply replace your new windows url in previous one??

or get the reference to the old window and than close it using reference. like.

var win = window.open("about:blank", "_self");
win.close();

or you can left the first parameter value blank.

1 solution

This code is abusive, to certain extent. You are opening new windows by code, which is equivalent to creation of pop-up window. This is considered as evil, and many users will block it. And then you try to close a current window, without user's consent. If some site does it to me, I usually put it to my black list. This is nasty.

I suggest you review this design. Logically, your code is equivalent to redirection to other URL, and this is what you should do. You force the user's browser window size and other parameter, but you don't know and don't use the screen size. How you know that the user would like it? The size of the window should be decided by the user, in almost all cases.

One more problem: there are no situations where a hard-coded file path, such as your "C:/Program Files/ViewWise Online" can be useful. How do you know that a client even has such thing as disk "C:". Even on Windows, this is not always the case, and on other platforms those stupid "C:" and "D:" never exist. Again, this design is unacceptable.

What to do? You can get an advice is you share your ultimate goals.

—SA
 
Share this answer
 
Comments
Rayan Khan 5-Nov-13 2:21am    
Hi,
can you plz modify this code:
window.open("Sign.asp?Home=C:/Program Files/ViewWise Online&VWOFlavor=Full","myWindow",'top=0,left=0,width='+screen.width+',height='+screen.height+',status=yes,resizable=no,scrollbars=yes');

C:/Program Files/ViewWise Online&VWOFlavor=Full: this is hard code if i want to check wheather this file is there then what change i have to do..
Sergey Alexandrovich Kryukov 5-Nov-13 2:28am    
Modify what? The point is: the whole idea is wrong. If you explain the ultimate purpose of all this, I'll try to advise.
—SA
Rayan Khan 5-Nov-13 2:32am    
window.open("Sign.asp?Home=C:/Program Files/ViewWise Online&VWOFlavor=Full","myWindow",'top=0,left=0,width='+screen.width+',height='+screen.height+',status=yes,resizable=no,scrollbars=yes');

with this code we open sign.asp page and that path is hard code , now if i want to open the sign.asp after verifying that floder in the local computer what code i have to write.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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