PDA

View Full Version : using onclick to open window at one size. Need size to change on next command...


studogvetmed
10-06-2004, 06:18 PM
Hi all. To try to clean up my layout on one of my pages I decided to try to open a new window when someone clicks on information about me. I use the following.

<a href="index.html#top" onClick="window.open('nickname.htm', 'browser', config='height=700', width='500')">Nickname</a> | <a href="index.html#top" onClick="window.open('life.htm', 'browser', config='height=700', width='500')">Life</a>

So this opens a new window for that at a particular size. In this case 700 x 500 because of how much text is there, but in other cases I could have it open much less. The new page has a whole bar of links as such:

<a href="broadway.htm" onClick="window.open('broadway.htm', 'browser', config='height=500', width='500')">Broadway Aspirations</a> | <a href="travel.htm" onClick="window.open('travel.htm', 'browser', config='height=500', width='500')">World Travel</a>

If someone clicks on the link it loads the new page directly into the window that was opened previously. All the while, the original front page stays at it's top point.

So as it should be, if someone opened the large window first in going to the smaller one, the window should reduce in size, but more importantly, if they start out in a smaller window and click on the link for the bigger window, the window needs to get bigger to prevent having to scroll. At least that is the idea.

I do notice now in the code I just posted I have the '' only around the number in width and around entire phras for height... Could this be part of the problem, or am I going about the idea the wrong way?

You can be taken directly to this part of my page through this URL: http://homepage.mac.com/studogvetmed/homepages/index.html#top

Any comments, suggestions, or better yet, the answer to my problem would be appreciated.

Cheers,
Stuart

maxadim
10-07-2004, 11:24 AM
Try this:

<script language="JavaScript1.2">
function ResizeWindow(height,width)
{
if (document.all) {
top.window.resizeTo(width,height);
}
else if (document.layers||document.getElementById) {
if (top.window.outerHeight<height||top.window.outerWidth<width){
top.window.outerHeight = height;
top.window.outerWidth = height;
}
}
}
</script>

studogvetmed
10-07-2004, 11:39 AM
Thanks for the suggestion.

A new layer just opened up as well. I downloaded firefox yesterday since so many people have talked about it. I wanted to see how my site looked in firefox (Not that my site counter has indicated many people in firefox are hitting my page, but I wanted to check). Well the code as original functioning doesn't even work in firefox. I get an error: Setting a property that only has a getter.

<edit> I finally went back and played with my original code. Found out I was right and were I have my quotes was preventing the original size of the window... I now have that fixed to a degree, but need to get the window to resize when the next one is called, now. Getting the quotes fixed got it working in firefox, at least on the first click.

My thought in doing this is to prevent having the long listing of text in my main page and to also escape my old stand by of vertical blocks of text separated by a horizontal rule and navigated by multiple anchors, but perhaps that is the way to go just on one separate page...

Thanks for your reply.
Stuart

studogvetmed
10-07-2004, 02:43 PM
Hi again,

I've worked on stripping the config commands from the links as previously. I then added the suggested script above to my <head> tag on one of the new pages. Then into the <body> I tried multiple ways of calling the script with onLoad="ResizeWindow()" and with ="ResizeWindow(height,width)" I then tried given the numbers I wanted like ...('600,300') and even ...('600',300')

I'm still so new to this javascript thing. I've tried searching a couple of places for the answer, but am at a lost at the best way to implement this script.

Thank you,
Stuart

maxadim
10-07-2004, 02:54 PM
Oh sorry misunderstood you a bit. If you just want to resize it onLoad just use this code

onLoad="window.resizeTo(500,500)"

Hope this helps

studogvetmed
10-07-2004, 06:29 PM
Nah, I don't think you misunderstood, I think I may have misunderstood the best way to use your suggested code. I mean originally I thought of putting the code associated with a click on each link.

I'm wondering if the resize on load maybe just the simpilest way now that I continue to think about it. Give each page it's resize when the page initially loads and hopefully presto.

Thanks again for the code.

studogvetmed
10-08-2004, 12:41 AM
The window resize function doesn't seem to be working either on my couple of tests.

I've prepared a seperate page with horizontal rules and anchors :-) I haven't put that one online yet, but it will be ready if I can't figure this one out.

Stuart