Click to See Complete Forum and Search --> : contrained window on click of link
sidthelizard
01-31-2003, 11:44 AM
Bit of a new coder here, and I'm trying to get this one thing to work. What I'm trying to do is have a window open when a link is selected, and for that window to be contrained without scroll or tool bars. Right now the best I can do is this:
<!--
window.open ('index.html', 'newwindow', config='height=403,width=403, toolbar=no,menubar=no, scrollbars=no, resizable=no,location=no, directories=no, status=no')
-->
Unfortunately, this runs when the page loads rather than when a link is selected. How could I modify this, or what should I use?
Zach Elfers
01-31-2003, 11:51 AM
<script language="JavaScript" type="text/JavaScript">
<!--
function newWin() {
newWin = window.open(blah);
newWin.focus();
}
//-->
</script>
...
<a href="" onClick="newWin();">Text</a>
sidthelizard
01-31-2003, 12:11 PM
Thanks for the speedy response, but i'm afraid I'm not entirely sure how to integrate the code. I added the new piece of code making the script for newWin() and then changed the href link to reflect the object. Unfortunately, I'm unsure where I input the formating. Thanks again for the help.
Zach Elfers
01-31-2003, 12:13 PM
Paste the script into the <head> section.
Then make the link:
<a href="" onClick="newWin();">Text</a>
You could also do:
<a href="javascript:newWin();">Text</a>
but that isn't correct code.
sidthelizard
01-31-2003, 12:50 PM
So the madness continues. I had everything in the right place it seems, and now a new question arises. I assumed that where 'blah' lives in the code you gave me I was to paste my formatting code. So I did. Unfortunately, it didn't load a contrained window when I selected my link. I tried altering the part of my code by getting rid of the reference window.open (.'index.html' , 'newwindow', config='height=403,width=403, toolbar=no,menubar=no, scrollbars=no, resizable=no,location=no, directories=no, status=no'), but trouble still arose. For all of you out there who know what you're (especially my new benefactor who has shared these tidbits with me), I apologize for the butchery of your code. So to recap, when I select the link, 2 windows open. The first is a page with the message 'page cannot be loaded', and second my desired page, not contrained in any way.
On this same line of thought, is it possible to have a window open contrained without being generated from another window or coming from a selected link. When I click on the html file can it open to my desired format? So many questions. Bah
Zach Elfers
01-31-2003, 01:01 PM
here:
window.open("index.html","newWin","width=100,height=100,menubar=0,status=0,toolbar=0,directories=0,scrollbar=0,resizable=0");
You can also substitute the 0's for "no". It is just a matter of style.
sidthelizard
01-31-2003, 01:41 PM
Almost there I believe. So here is the story thus far. Now when I click on my link, 2 windows open. The first window is the one included in the script (index.html in this case), and the second is the page referenced from the link (the one associated with the href command).
The first window that opens is contrained like no other, perfect in form. The problem is that I'm much more interested in the second window. In fact, I don't want the first window at all. What I would like is that each individual href link would open up its own specified page in a new window according to my desired contraints. Is this possible? I tried canning the index.html line from the object, but that only resulted in 1 window (which was good), unconstrained (which was bad). Sometimes code is even more difficult to understand than women.
Zach Elfers
01-31-2003, 01:47 PM
Why are two windows opening? I guess you have:
<a href="link.html" onClick="newWin();">Text</a>
In this case, just do:
<a href="" onClick="newWin();">Text</a>
This way only one window will open and it should be the way you want it.
sidthelizard
01-31-2003, 02:04 PM
Deepest thanks, it finally works! Now due to my limited programing knowledge more questions arise. If I wanted to have multiple pages open from multiple links, would I need one of these objects for each new html file I want to display? If so, life goes on I suppose.
The other question I had earlier was what I can do to constrain the initial html file without having a linked or pre-loading page directing to it? I need to have a menu file on this cd I'm compiling, so when the autorun selects the index file, what can I do to constrain it? Are my options limited?