Forum Moderators: open
I have managed to do it by putting the following script in the head of the new page which works fine.
<script>
function sizeMe() {
window.moveTo(10,10);
window.resizeTo(500,300)
}
</script>
This is called up by <body onload="javascript:sizeMe('myInfo.htm')">
What I want to do now is make it a minimal window with only the title bar showing. That is no Toolbar, no scrolling etc.
Can anybody help by supplying some code to add to the above script please?
There is a firm reason for not wanting Javascript in the parent page.
The title bar is required to allow the window to be closed.
It would also be nice but not essential to make the new window always on top.
Thanks in advance.
I'm afraid most of what you want can't be done - easily, at least.
This is called up by <body onload="javascript:sizeMe('myInfo.htm')">
This isn't actually necessary, both the statements could be put in a SCRIPT block in the HEAD, without a function, and executed immediately. The new win wouldn't have to load before it jumped and resized.
What I want to do now is make it a minimal window with only the title bar showing. That is no Toolbar, etc.
This absolutely cannot be done once the window has been created. The only way you can make a 'minimal' window is by setting those features when using
open() to open the window, but that requires Javascript in the launching page no scrolling
set:
body{overflow:hidden;} to make the new window always on top
<body onblur="window.focus()"> This makes the window bounce back.
IE has the alternatives:
showModalDialog()
showModelessDialog() ..but these, again, require JS in the launching page.
There is a firm reason for not wanting Javascript in the parent page
What's that (If I may be so bold)?
Perhaps we can get around the issue somehow.
I will take in what you say and go forward from there.
I did have a script working (beta version) that opened the new window to the actual size of the contained image but I accidentaly overwrote it and can't come up with it again.
The reason that I want to completely remove Javascript from the main pages within the site is because I have a theory that some search engines will rate straight HTML pages higher than those containing Javascript.
I have some quite mature pages with unexplained stickiness in the lower results and would like to try removing the Javascript (as the only change)to observe the positional change if any. These pages have been unchanged for a little while now so any change would be either algo tweaks or give some weight to my theory.
I have also just come accross this but not yet tried it.
<form method="POST" action="/cgi-bin/live/judges.cgi" target="judges" onsubmit="window.open('about:blank','judges','width=750,height=700,menubar=no,toobar=no,scrollbars=no,resizable=no' )">
<input type="image" src="pathtoimage" value="formula Help ">
</form>
What do you think?
The reason that I want to completely remove Javascript from the main pages within the site is because I have a theory that some search engines will rate straight HTML pages higher than those containing Javascript.
Hmmm. There are a fair few SEO experts around these parts, but I'm not one of them.
Certainly, if your script is in an on-page script block, then it will have some effect on SE's. That's just more stuff for them to wade through. I don't think they mind it so much (or at all) if the script is linked externally. You could put the linked script tag at the bottom of the page to ease any concerns.
[I can't think of any reason why that would be considered wrong]
But, you may be thinking that some SE's actually penalise the use of <script> tags. I haven't heard of it - but who knows?
In that case, you can put the window opening code inside an event handler (or an
[blue]href[/blue], with [blue]javascript:[/blue]). That's what you've done in your FORM snippet, and it seems to shoot 2 pigeons with one bullet. I've never seen that before. It opens the
[blue]action[/blue] URL in the new window [blue]about:blank[/blue], leaving that arg as [blue]''[/blue]). Seems quite good. I've been missing out.
I struggle with JavaScript and just about manage to customise simple scripts that I find here or elsewhere on the net. I have however copied and printed the "JavaScript JumpStart" series but now need to find the free time to work through and absorb.
That "form" method is strange, I can get it to work on my desktop PC but not on the Cpanel Unix server where it's needed. Early days for this one lots of options to try yet.
By the way, have you any idea how I can introduce the no toolbar no scrolling etc to this script which sizes the browser window according to the width and height or the image contained.
<SCRIPT LANGUAGE="JavaScript">
var isNav4, isIE4;
if (parseInt(navigator.appVersion.charAt(0)) >= 4) {
isNav4 = (navigator.appName == "Netscape")? 1 : 0;
isIE4 = (navigator.appName.indexOf("Microsoft")!= -1)? 1 : 0;
}
function fitWindowSize() {
if (isNav4) {
window.innerWidth = document.layers[0].document.images[0].width;
window.innerHeight = document.layers[0].document.images[0].height;
}
if (isIE4) {
window.resizeTo(500, 500);
width = 500 - (document.body.clientWidth - document.images[0].width);
height = 500 - (document.body.clientHeight - document.images[0].height);
window.resizeTo(width, height);
}
}
</script>
<BODY onLoad="fitWindowSize()">
If that can be done, I think it will fit my requirements because the site/s I will use it on are 90%+ IE and this method degrades functionaly in non supporting browsers.
[also] Have a look around for a better (much more up-to-date) browser sniffer. New Mozilla browsers may not feature "Netscape". At the moment, the code defaults to doing nothing if the browser isn't one of the two - perhaps your intention, sorry.
Be aware that browsers often lie about what they are.
Here is the latest thread:[webmasterworld.com ]
I've seen some good scripts for resizing to content. If I find one of them again I'll let you know.
Pages by themselves are about 15k of html with "onload calls" to "handler" files of around 11k and 8k depending what flavour browser they get ...
Why do you want to "strip" the "windows" ..?
Firstly my theory or suspicion may or may not be groundless but I feel the need to prove one way or the other.
Secondly, I am calling a new window to display a larger image and with a fully equiped browser window with whistles and bells like Google or Alexa toolbars etc, when displayed on an 800x600 screen there is only about 425px useable height left without scrolling.
I display such a window at the moment but that is using JS in the calling page. What I don't want is to have to call smaller images to accommodate non essential second window browser functions.
I am not trying to strip out the ability to close the window or anything sinister, I just want to display a decent size image without vertical scrolls being forced by redundant knobs/buttons and bells. The title and closing/minimising controls will still be there.