Wrox Programmer Forums
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old July 9th, 2003, 09:38 AM
Registered User
Join Date: Jul 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Disabling browser

I have a form which holds a close button. I need to know that if there is any way that I can force the user to only close the window through that close button. Behind the button I have called java script "window.close();" after some of my own stuff. My problem is that the user can also close the window through the right top "X" button of browser. Is there any way I can disable or somehow make it non-working? That way I will be sure that the page is always closed through close button provided on the page. Any help will be appreciated.
Old July 9th, 2003, 02:03 PM
Registered User
Join Date: Jul 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts

in head:


//DHTML Window script- Copyright Dynamic Drive (http://www.dynamicdrive.com)
//For full source code, documentation, and terms of usage,
//Visit http://www.dynamicdrive.com/dynamici...htmlwindow.htm

var dragapproved=false
var minrestore=0
var initialwidth,initialheight
var ie5=document.all&&document.getElementById
var ns6=document.getElementById&&!document.all

function iecompattest(){
return (document.compatMode!="BackCompat")? document.documentElement : document.body

function drag_drop(e){
if (ie5&&dragapproved&&event.button==1){
document.getElementById("dwindow").style.left=temp x+event.clientX-offsetx+"px"
document.getElementById("dwindow").style.top=tempy +event.clientY-offsety+"px"
else if (ns6&&dragapproved){
document.getElementById("dwindow").style.left=temp x+e.clientX-offsetx+"px"
document.getElementById("dwindow").style.top=tempy +e.clientY-offsety+"px"

function initializedrag(e){
offsetx=ie5? event.clientX : e.clientX
offsety=ie5? event.clientY : e.clientY
document.getElementById("dwindowcontent").style.di splay="none" //extra
tempx=parseInt(document.getElementById("dwindow"). style.left)
tempy=parseInt(document.getElementById("dwindow"). style.top)

document.getElementById("dwindow").onmousemove=dra g_drop

function loadwindow(url,width,height){
if (!ie5&&!ns6)
window.open(url,"","width=width,height=height,scro llbars=1")
document.getElementById("dwindow").style.display=' '
document.getElementById("dwindow").style.width=ini tialwidth=width+"px"
document.getElementById("dwindow").style.height=in itialheight=height+"px"
document.getElementById("dwindow").style.left="30p x"
document.getElementById("dwindow").style.top=ns6? window.pageYOffset*1+30+"px" : iecompattest().scrollTop*1+30+"px"

function maximize(){
if (minrestore==0){
minrestore=1 //maximize window
document.getElementById("maxname").setAttribute("s rc","restore.gif")
document.getElementById("dwindow").style.width=ns6 ? window.innerWidth-20+"px" : iecompattest().clientWidth+"px"
document.getElementById("dwindow").style.height=ns 6? window.innerHeight-20+"px" : iecompattest().clientHeight+"px"
minrestore=0 //restore window
document.getElementById("maxname").setAttribute("s rc","max.gif")
document.getElementById("dwindow").style.width=ini tialwidth
document.getElementById("dwindow").style.height=in itialheight
document.getElementById("dwindow").style.left=ns6? window.pageXOffset+"px" : iecompattest().scrollLeft+"px"
document.getElementById("dwindow").style.top=ns6? window.pageYOffset+"px" : iecompattest().scrollTop+"px"

function closeit(){
document.getElementById("dwindow").style.display=" none"

function stopdrag(){
document.getElementById("dwindow").onmousemove=nul l;
document.getElementById("dwindowcontent").style.di splay="" //extra


in body:

<div id="dwindow" style="position:absolute;background-color:#EBEBEB;cursor:hand;left:0px;top:0px;display :none" onMousedown="initializedrag(event)" onMouseup="stopdrag()" onSelectStart="return false">
<div id="dwindowcontent" style="height:100%">
<iframe id="cframe" src="" width=100% height=100%></iframe>

//Use below code to load DHTML Window as page loads
if (ns6) window.onload=new Function('loadwindow("http://www.google.com",600,400)')

<a href="javascript:loadwindow('http://www.google.com',600,400)">Geocities</a>

Similar Threads
Thread Thread Starter Forum Replies Last Post
Disabling Back button of browser software_developer_kk Classic ASP Basics 7 September 27th, 2007 03:22 PM
Launch default browser in a new browser window haiying Beginning VB 6 1 August 30th, 2005 05:48 PM
disabling the toolbar g_srinivas Javascript 6 July 25th, 2004 09:56 AM
Disabling Refresh mildge Beginning PHP 1 December 22nd, 2003 01:00 PM
Is there any way of disabling logging? chrislepingwell SQL Server 2000 1 October 9th, 2003 11:52 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.