PDA

View Full Version : DHTML Window Size Question



iblob
04-26-2006, 06:44 AM
Script: DHTML Window
http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow.htm

Okay this script works awesome.. just a couple things, how would I be able to get the div to open maximized to begin with. So when people click the button to open the window, it will open it maximized all the way no matter the browsers size.

I need it to do that for my arcade script, im using this as a "boss/teacher hide" feature so it looks like they are on google. :p

jscheuer1
04-26-2006, 08:49 AM
A DHTML window can never be larger than the browser. If you need to open a full size window using minimal 'chrome', use the window.open() method:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<script type="text/javascript">

function fullwin(targeturl){
var h=screen.availHeight, w=screen.availWidth
var full=window.open(targeturl,"","top=0,left=0,width="+w+",height="+h+",scrollbars=1")
if (document.documentElement.filters)
full.resizeTo(w,h);
}

</script>
<form>
<input type="button" onClick="fullwin('somepage.htm')" value="Open window">
</form>
</head>
<body>

</body>
</html>

You can have somepage.htm be whatever page you like, as long as it is on the same domain as the above opener page.

iblob
04-26-2006, 11:10 PM
That works nice but I was hoping that it could actually hide my site so if the instructor was to click on the browser window that my site is in then they wouldnt be able to see the site there but instead see google. Thanks!

jscheuer1
04-27-2006, 06:08 AM
Sorry I didn't understand the question at first. Try this (To close the Google 'page', put the mouse pointer near the top of the window and, when it becomes a pointing hand, click):


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>

<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">

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

var ie5=document.all&&document.getElementById
var ns6=document.getElementById&&!document.all

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

function loadwindow(url){
if (!ie5&&!ns6)
window.open(url,"","width="+screen.width"+,height="+screen.height+",scrollbars=1")
else{
//maximize window
document.getElementById("dwindow").style.width=window.innerWidth? window.innerWidth-20+"px" : iecompattest().clientWidth+"px"
document.getElementById("dwindow").style.height=window.innerHeight? window.innerHeight-20+"px" : iecompattest().clientHeight+"px"
document.getElementById("dwindow").style.left=0
document.getElementById("dwindow").style.top=0
document.getElementById("dwindow").style.display=''
document.getElementById("cframe").src=url
}
}

function closeit(){
document.getElementById('cframe').src="about:blank"
document.getElementById("dwindow").style.display="none"
}
</script>
</head>

<body>

<div id="dwindow" style="position:absolute;background-color:white;cursor:pointer;left:0px;top:0px;display:none" onMousedown="closeit()" onSelectStart="return false">
<div align="right" style="background-color:white;height:10px;"></div>
<div id="dwindowcontent" style="height:100%">
<iframe id="cframe" src="about:blank" width=100% height=100% frameborder="0" scrolling="0"></iframe>
</div>
</div>



<!--Use below code to load DHTML window via link-->
<a href="javascript:void(0);" onclick="loadwindow('http://www.google.com');return false;">Geocities</a>
</body>

</html>

iblob
04-27-2006, 07:27 AM
Thanks its awesome!!

EZboy
07-06-2006, 04:41 PM
is there a way to change the top bar in the window to some other color, currently its blue. Thanks

EZboy
07-07-2006, 02:37 PM
bump, pleASe help

jscheuer1
07-08-2006, 05:04 AM
is there a way to change the top bar in the window to some other color, currently its blue. Thanks

Yes, here is the HTML portion of this script from the demo page:


<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 align="right" style="background-color:navy"><img src="max.gif" id="maxname" onClick="maximize()"><img src="close.gif" onClick="closeit()"></div>
<div id="dwindowcontent" style="height:100%">
<iframe id="cframe" src="" width=100% height=100%></iframe>
</div>
</div>

See the red highlighted color name? You can change this to any valid HTML color name or hex value (examples: red or #ffd044).

EZboy
07-18-2006, 06:02 PM
Thanks a lot, changed the colour, all is good

iblob
09-14-2006, 11:42 PM
Hello, been awhile, but I am using this code once again, except im getting that "Done. But with errors" message in the status bar of IE.

Of course It doesnt give any hint as to what it is doing wrong other then what line it is.. and that line is this:

function closeit(){


Which is part of this part of the code you gave me:

function closeit(){
document.getElementById('cframe').src="about:blank"
document.getElementById("dwindow").style.display="none"
}


The window is coming up perfectly fine, but it would be nice if my site doesnt say it has errors to the visitors.

iblob
09-15-2006, 01:41 AM
Um oops, nevermind, something I did thats totally not related to this at all :)

(had the javascript code in another file, and messed up the path to that file.)

iwdynamic
09-19-2006, 12:49 AM
Can the script be modified to add "Close It" link at the top to close the windiw instead of moving the mouse pointer to the top to find the spot where a user can close the window?


Sorry I didn't understand the question at first. Try this (To close the Google 'page', put the mouse pointer near the top of the window and, when it becomes a pointing hand, click):

jscheuer1
09-19-2006, 03:58 AM
Can the script be modified to add "Close It" link at the top to close the windiw instead of moving the mouse pointer to the top to find the spot where a user can close the window?

That is how the unmodified version of the script works.

muguran
10-31-2006, 02:35 PM
From page loaded in dhtml window is posible to close this window?

Thank you.

jscheuer1
10-31-2006, 04:46 PM
From page loaded in dhtml window is posible to close this window?

Thank you.

Just put this on your page:


<span style="cursor:pointer;" title="Close It" onclick="closeit();">Close It</span>

muguran
10-31-2006, 05:17 PM
I think I was missunderstood: I want to close the dhtml window from a page loaded in it.
close() function is not known from this point...

jscheuer1
10-31-2006, 06:06 PM
As long as the content is on the same domain:


<span style="cursor:pointer;" title="Close It" onclick="parent.closeit();">Close It</span>

muguran
11-01-2006, 09:01 AM
Is working very good.

Thank you. :)