Click to See Complete Forum and Search --> : Closing Current window without confirmation alert in IE
I tried to open a pop-window from the onload() of current window.
In onload() I also wanted to close the parent window.
I tried window.close() with IE. But IE asks client user to confirm the closing of window.
How can I close the parent window after loading a pop-up without any confirmation box?
sciguyryan
09-30-2004, 12:34 PM
Sorry, this can not be done without Netscape signed scripts or, adding the user adding the site to their trust site list (But, in most versions of IE it still asks all the same.)
This is one of those things that Javascript has absolutley no control over.
RyanJ
Oh!, Better to go with another idea.
Anyway, ThanX for your reply.
Regards
jackacohen
10-01-2004, 06:55 PM
Although you don't say so explicitly, from what you describe (opening another window when the first one loads, then trying to close the original window) it sounds as though you may be trying to "hide" something in the original window.
If that's the case, you can have the second window "write" to the first, which will remove its original contents (that's the workaround I ended up using.)
I have a web page containg my own code an I want to disable any posibilities with client visitor is enabled to get the code.
1. I can disable the right click.
2. Then user can choose menu. : [View] ==> [Source]
3. Then I load a popup with no menubar, toolbars, addressbar.
4. Then user can track the code of parent window and can find the absolute URL of the popup page.
5. Then he can type it on the browser and will be able to get the code easily.
6. So, I want to close the parent window after opening the pop-up.
I want a reslove this.
Regards
Jupac
10-02-2004, 11:08 AM
NEVER EVER DISABLE RIGHT CLICK
Willy Duitt
10-02-2004, 11:20 AM
Originally posted by GUIR
I have a web page containg my own code an I want to disable any posibilities with client visitor is enabled to get the code.
1. I can disable the right click.
2. Then user can choose menu. : [View] ==> [Source]
3. Then I load a popup with no menubar, toolbars, addressbar.
4. Then user can track the code of parent window and can find the absolute URL of the popup page.
5. Then he can type it on the browser and will be able to get the code easily.
6. So, I want to close the parent window after opening the pop-up.
I want a reslove this.
Regards
ROTFLMAO....
And then after all of that trouble...
The least knowledgeable user can either take get your source by validating your page at W3C or get the source, the IP# and more here (http://web-sniffer.net/)....
Besides, SP2 does not allow you to open a window without addressbar, toolbar and statusbar... Thanks for the laugh tho... :)
.....Willy
Vladdy
10-02-2004, 11:53 AM
WWW Axiom #1: "One's desire to hide his/her code is inversely proportional to the quality of that code" :D :D :D :D :D
David Harrison
10-02-2004, 06:41 PM
Originally posted by GUIR
I can disable the right click.You sure about that? As far as I am aware no-right-click scripts don't work on the better browsers.
In any case, if you use a PC (not sure about Mac's) there's a little button next to right control on the keyboard that will open up the context menu.
Hiding your code is a pointless activity, the only people who will want to look at your code will be developers, and they can probably replicate what you've done anyway.
If you write good clean code, then you should want people to see it so that they can see how good you are. If you don't write good clean code then ... well ... like everyone's been saying, the most determined will be able to see it anyway.
Have you contemplated that not all of your users will have JavaScript enabled? If JavaScript is not enabled then none of your prevention measures will work.
Paul Jr
10-02-2004, 09:10 PM
Originally posted by GUIR
I have a web page containg my own code an I want to disable any posibilities with client visitor is enabled to get the code.
It isn’t usually good to say something like this, but I think we can make an exception: give up right now; it is not possible, no matter which way you slice it, to keep someone from nabbing your code. Having said that, did you read the sticky?
P.S.: Vladdy, lol, nice one. :D :D :D
sciguyryan
10-03-2004, 06:22 AM
Yea, if someone was intent on getting your code there is no way to stop them, The view-source URL will do it all for you and so will the w3c HTML / XHTML syntax checker.
So, the best alternative is to leave the right click there.
RyanJ
glenmac
10-03-2004, 09:56 AM
There is a hack for closing windows in IE without a warning. Although I've heard that it won't work for much longer.
<html>
<head>
<script>
function bye() {
self.opener = this;
self.close()
}
</script>
</head>
<body>
<a href="JavaScript: bye()">Bye bye</a>
</body>
</html>
Hope that helps.
sciguyryan
10-03-2004, 10:15 AM
Originally posted by glenmac
There is a hack for closing windows in IE without a warning. Although I've heard that it won't work for much longer.
<html>
<head>
<script>
function bye() {
self.opener = this;
self.close()
}
</script>
</head>
<body>
<a href="JavaScript: bye()">Bye bye</a>
</body>
</html>
Hope that helps.
An interesting trick but, it does not seem to work with the new XP SP2 or FF.
Although it may be the changes I just made to the Registry :D
Ryanj
I also agree on what all of U said. However there may be exceptions on anything=We can take any security action on anything+But there may be people crawl through security pathces.For a example assume the following scenario.
You have some copyrighted images. You want to show them in a web page.But u don't need anyone to copy/save those images.
There are some steps I'll do.
1. Disable the right click event of such images. <img src="aa.jpg" onMouseDown="disableRight()">
Then others will able to view source and find the url of image by "src".
2. Then Disable the right click of <body>.
Then anyone may use menubar to view source.See the URL of web page by URL in address bar. He can use also a web copier.
3. Then loading a popup without no menubar, address bar or toolbar.
There is still parent window of popup is open.User can get the URL of Popup by Menu[View Source] of Parent, eventhough its right click is disabled.
Then he can type popup's URL in the browser, directly view it, view its source, find "<img src=". Type images absolute URL in browser, view it, save it.
4. OK!, Problem get resolved if u close parent window after doing popup.
5. You may also use "<Body onSelect=" to avoid copying contents online.
6. Ooops! If u did it anyhow, user can find the webpage/images from "Temporary Files" or use "Web Copier" to view server's content and then download web pages/images.There may also other alternatives.
7. There are limited no of people doing the sixth step.
8. Therefore, I think doing things against unauthorized copying as much as possible, is better than doing nothing.
What about hiding menubar, addressbar, toolbar of a window itself.
File > Save (page) as ...
Any image is now available to me :rolleyes:
What if menu bar was hide in popup, redirecting parent.
sciguyryan
10-03-2004, 01:44 PM
Originally posted by GUIR
What if menu bar was hide in popup, redirecting parent.
Well, that will not stop anyone who know the shortcut key:
Alt, V, C :rolleyes:
Trust me trying to hide your source is pointless as is trying to stop them right clicking, etc.
If you try stoping it though javascript all they have to dio is disable Javascript, get your source and then re-enable Javascript its that simple.
RyanJ
Paul Jr
10-03-2004, 01:49 PM
Originally posted by GUIR
You have some copyrighted images. You want to show them in a web page.But u don't need anyone to copy/save those images.
There are only a few things you could do. You could only show part of the image; you could reduce the quality so much that the image is basically unusable; you could watermark the image. Those are about the only half-way effective steps you can take. There is a good saying for this kind of thing, “if it’s on the internet, someone can get it”. Any of the steps you are trying to take are not going to prevent people from taking your images, rather annoy them, possibly to the point of them leaving your site. If I went to a site that removed some browser/keyboard/mouse function I use, I would just leave.
Disable right-click? You can just go View -> Source. No menu bar? Hit the key to the immediate left the the right Ctrl key, and you get the context menu (the menu you get when you right-click). Disable that? Take a screenshot of the page — you cannot disable the print screen button. Everything is also cached, including images. There is a myriad of ways for someone to take whatever they want from your site, and you cannot stop them.
sciguyryan
10-03-2004, 02:09 PM
Originally posted by Paul Jr
Disable right-click? You can just go View -> Source. No menu bar? Hit the key to the immediate left the the right Ctrl key, and you get the context menu (the menu you get when you right-click). Disable that? Take a screenshot of the page — you cannot disable the print screen button. Everything is also cached, including images. There is a myriad of ways for someone to take whatever they want from your site, and you cannot stop them.
Thats the best description so far :D.
RyanJ
jackacohen
10-03-2004, 08:56 PM
If I understand the discussion correctly, ikt seems to have gotten a bit off track from the original question.
What was asked was about hiding the PARENT window.
MY interest in doing so was NOT to protect my code. It was in the context of a teaching-program: the original window contains the source of the various lesson modules and users can't (shouldn't) access future lessons until they've completed the current one. So after opening the second window, the one with the lesson, I wrote to the parent, which erased its content and its source.
If the user accessed the original window via a link (rather than by typing in a URL) will this hide the parent's URL?
Paul Jr
10-03-2004, 10:11 PM
Originally posted by jackacohen
If I understand the discussion correctly, ikt seems to have gotten a bit off track from the original question.
Seems ontopic to me. The OP was trying to close the parent window as a method of hiding his source code.
If any sort of content on a webpage wants to be hidden, or restrict access to it, the most reliable way is through user logins. If you want only certain people to be able to access something, have them log in to see it. Nothing can be “hidden” effectively (or sometimes at all) with JS.
jackacohen
10-04-2004, 01:03 AM
Sorry if I misunderstood - I don't think anyone ever linked those two ideas explicitly in this thread. If the parent window held the source code (and didn't write it to the child window) wouldn't closing the parent window disable the code? I assumed (without any consideration) that it would, which is why I also assumed it was the parent window's code which he wanted to hide - as in the education case I described - since closing the parent window wouldn't protect any code in the child. And my perception was that posts were considering how to protect the child window - since things like omitting the toolbar wouldn't (to the best of my knowledge) be an option in the parent window.
But I'm new, so PLEASE tell me if any of the assumptions I've stated are wrong. And if they were not off topic, I apologize.
David Harrison
10-04-2004, 08:12 AM
Closing the parent window won't affect the child window's source code, simple as.
JPnyc
10-04-2004, 08:13 AM
No, he wants to use the parent window to open a child window with no toolbars or menu, or addy bar, and disabling r-click, to hide the source of the CHILD window.
I have an another idea.
Suppose, we have three web pages. (index.htm, index2.htm, pop.htm)
pop.htm : popup page.
index.htm : There we load a popup without any controllers, then redirecting parent window to index.htm.
index2.htm : On its UnLoad event it'll be redirected to itself.Also we can use an advertisement(s) here.
Problem seems to be little bit received.
But a new problem arises if we want to keep the popup being focused through its lifetime.After loading popup, and redirecting parent window, parent window will then focused.
How to keep popup focused all its life.
David Harrison
10-04-2004, 01:55 PM
Well I don't really understand what you're saying, but you don't seem to understand what we're saying either. It is not possible to hide the source code of a page that the user is viewing. There is always a way to find the source code.
Additional information: There is no such event handler as "onunload", despite what Micro$oft would have you believe.
You shouldn't rely on client-side JavaScript to display your pages, not everyone has it enabled (1 in 10 people don't).
What is so precious about your source code that you don't want it displayed?
DThomas
10-04-2004, 03:00 PM
For an internal, IE application, we use the following code to get rid of the parent window so we can open a new one without buttons and stuff:
function popViewer(currentWindow, mfSessionID, doSubmit) {
var windowName = buildWindowName(mfSessionID);
if(currentWindow.name == windowName){
currentWindow.focus();
if (doSubmit) {
document.body.style.cursor='wait';
process.submit();
}
}
else {
var newProcessURL = currentWindow.location.protocol + "//" + currentWindow.location.hostname + ":" + currentWindow.location.port + "/EnterpriseCommon/newprocesspageloader.jsp?windowname=" + windowName + "&origurl=" + escape(currentWindow.location);
var shell = new ActiveXObject("WScript.Shell");
shell.Run ("iexplore.exe " + newProcessURL, 7, false);
currentWindow.opener = null;
currentWindow.close();
}
}
We use the shell command so that we can start a new IE process because of some potential access violations we've seen when other windows have applets running. But you could just use a window.open to do the same thing. This, combined with a bunch of key code handling will minimize the opportunity for navigating in a way that wasn't intended. Of course, all of my users can still see my code.
Anyway, the reason I posted this is to point out that this works in XP SP2. Well... at least it does for me. :) ...and it seems like something that might come in handy for anyone building an internal application.
Hope this helps someone.
DThomas
10-04-2004, 03:05 PM
I tried to delete this post, but I don't seem to have permission. Sorry.
Willy Duitt
10-04-2004, 03:59 PM
Originally posted by GUIR
index2.htm : On its UnLoad event it'll be redirected to itself.Also we can use an advertisement(s) here.
Gheesh it's people like you that give programmers a bad name!:rolleyes:
If I want to browse away from your page you have no right to attempt to keep me on the page by having it spawn itself over and over...
.....Willy
Brasuca
10-04-2004, 08:34 PM
Originally posted by Willy Duitt
Gheesh it's people like you that give programmers a bad name!:rolleyes:
If I want to browse away from your page you have no right to attempt to keep me on the page by having it spawn itself over and over...
.....Willy
Not if you put an if-then-else, based on a cookie.
Jupac
10-04-2004, 08:42 PM
Originally posted by Brasuca
Not if you put an if-then-else, based on a cookie.
You can eaily turn off javascript and disable cookies
Now, I do understand its very nearly impossible to hide source code.
Sometimes new persons to programming comes with strange ideas without knowing what's the scope of the language he is using.
Redirecting page to itself seems to be going beyond ethics.
However I think should someone find a way to tackle this, may be outside JavaScript.
Web designers want to show visitors only the content. Only browsers want the code.There should a way to show the content (obviously after downloading the code) and then throw out the downloaded items (Only if Designers want to do so, as they have rights on code) .
Is someone know a way to deal with aforesaid issues, by using other field other than JavaScript.
Regards.
David Harrison
10-05-2004, 02:49 PM
Originally posted by GUIR
Now, I do understand its very nearly impossible to hide source code.It's not very nearly impossible, it just IS impossible.
You can't really show breath-taking things on web-sites, the graphics are mostly static and virtually everything that can be coded already has been coded. The chances are you have nothing new and therefore there's no point trying to hide away your code because it's already out there somewhere (even if it was written by someone else).
DThomas
10-05-2004, 02:52 PM
The chances are you have nothing new and therefore there's no point trying to hide away your code because it's already out there somewhere
Couldn't agree more.
Originally posted by GUIR
Web designers want to show visitors only the content. Only browsers want the code.There should a way to show the content (obviously after downloading the code) and then throw out the downloaded items.
that's not how browsers work. if no code is downloaded, how on earth does a browser know what to do. code is a series of commands which tell a browser how to behave. if there are no commands, then there's also no content, because how the content is shown is how the browser bahaves.
Originally posted by GUIR
Is someone know a way to deal with aforesaid issues, by using other field other than JavaScript.
no.