Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jan 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    2 inner html problems in one page

    Heya
    OK I have tried this in another forum but the one I went to seemed to have no one who was interested in helping but plenty of spectators. I know its not *ethical* posting around the web it was my first post there and as they say "learn by your mistakes" well I'm learning.

    This window im working on isnít doing the same for both functions

    1) When I open window #1 (small window) and close the main screen using the close X button at the top of the page NOT the small window the small window remains on my desktop yet when I open window #2 and do the same thing everything closes which IS WHAT I want to happen

    This was pointed out to me as being an on focus problem but I dont know how to resolve it so that BOTH small windows close when ever the main page is closed.

    2) Also when I click anywhere on the back page around the small window when either small window # is open the small window minimizes to my taskbar even when I resize the main screen

    I have 2 Questions:

    1 ) Anyway of making window#1 do the same as window#2 so they both close when either one is open and the page is finished with
    (no smaller window left after the page is closed??)


    2 ) How do I stop the smaller window from either shrinking to the taskbar or dissapearing / closing completely when the main page is either resized or the mouse is clicked on the back page??

    I would like the small window to remain open untill it is either REPLACED with another window #1 or #2 or actually closed by using question 1

    One more thing if anyone can help. I really dont know alot about coding and this window took me an age to make simple instructions are all I ask for if someone would be kind enough to assist.

    Cheers and thanks





    <body bgcolor="#ffffff">

    <script language="JavaScript">

    var winheight=1;
    var winwidth=1;
    var TW=null;
    var speed=4;

    function testWindow(name,width,height,title) {
    if (!document.layers&&!document.all&&!document.getElementById) {
    paramstp="height="+height+",width="+width+",top=0"+",left=0,scrollbars=no"
    TW=window.open("","TW",paramstp);
    }
    LeftPosition=(screen.width)?(screen.width-width)/2:0;
    TopPosition=(screen.height)?(screen.height-height)/2:0;

    if (document.layers){paramstp="height="+",width="+",top="+TopPosition+",left="+LeftPosition+",scrollbar s=no"
    } else {
    paramstp="height="+winheight+",width="+winwidth+",top="+TopPosition+",left="+LeftPosition+",scrollba rs=no"
    }
    TW=window.open("","TW",paramstp);
    if (document.all) {string="<html><title>"+title+"</title><body topmargin=0 leftmargin=0>"+'<IFRAME src=TEST.htm width=250 height=250></IFRAME>'+'</body></html>';
    }
    if (document.getElementById&&!document.all) {
    toppos=height/2-0;
    leftpos=width/2-0;
    string="<html><title>"+title+"</title><IFRAME src=TEST.htm width=250 height=250></IFRAME>"+"</body></html>";

    x=y=speed;
    while (x | y) {
    TW.resizeBy (x, y);
    if (TW.window.innerWidth >= width) x=0;
    if (TW.window.innerHeight >= height) y=0;
    }
    }
    TW.document.writeln(string);

    if (document.all) {
    x=y=speed;
    while (x | y) {
    TW.resizeBy (x, y);
    if (TW.document.body.clientWidth >= width) x=0;
    if (TW.document.body.clientHeight >= height) y=0;
    }
    }
    }

    function CloseTWWin() {
    if(TW!=null && TW.open)TW.close()
    }
    window.onfocus=CloseTWWin;

    // =================
    // Start test Window 2
    // =================

    var TW2=null;

    function testWindow2(name,width,height,title) {
    if (!document.layers&&!document.all&&!document.getElementById) {
    paramstp="height="+height+",width="+width+",top=0"+",left=0,scrollbars=no"
    TW2=window.open("","TW2",paramstp);
    }
    LeftPosition=(screen.width)?(screen.width-width)/2:0;
    TopPosition=(screen.height)?(screen.height-height)/2:0;

    if (document.layers) {
    paramstp="height="+",width="+",top="+TopPosition+",left="+LeftPosition+",scrollbars=no"
    } else {
    paramstp="height="+winheight+",width="+winwidth+",top="+TopPosition+",left="+LeftPosition+",scrollba rs=no"
    }
    TW2=window.open("","TW2",paramstp);
    if (document.all) {
    string="<html><title>"+title+"</title><body topmargin=0 leftmargin=0>"+'<IFRAME src=TEST.htm width=250 height=250></IFRAME>'+'</body></html>';
    }
    if (document.getElementById&&!document.all) {
    toppos=height/2-0;
    leftpos=width/2-0;
    string="<html><title>"+title+"</title><IFRAME src=TEST.htm width=250 height=250></IFRAME>"+"</body></html>";

    x=y=speed;
    while (x | y) {
    TW2.resizeBy (x, y);
    if (TW2.window.innerWidth >= width) x=0;
    if (TW2.window.innerHeight >= height) y=0;
    }
    }
    TW2.document.writeln(string);

    if (document.all) {
    x=y=speed;
    while (x | y) {
    TW2.resizeBy (x, y);
    if (TW2.document.body.clientWidth >= width) x=0;
    if (TW2.document.body.clientHeight >= height) y=0;
    }
    }
    }

    function CloseTW2Win() {
    if(TW2!=null && TW2.open)TW2.close()
    }
    window.onfocus=CloseTW2Win;

    </script>

    <form>
    <P>
    <input type="button" value="--#1--" onclick="this.blur();testWindow('','250','250','Test1')" onfocus="this.blur()">
    <P>
    <input type="button" value="--#2--" onclick="this.blur();testWindow2('','250','250','Test2')" onfocus="this.blur()">
    </form>

  • #2
    New to the CF scene
    Join Date
    Jan 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Wow this forum moves fast can someone please help me here

  • #3
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    A a first glance I think your problem is due to the fact that you have simply duplicate some functions. You may have had used a parameter or something and passed it to a single function...

    The duplicate of functions always bring trubles, no wonder people avoid give you straight answer, as I can not give to you either.

    Anyway, besides the fact that you have some variables called the same, which may create confusing in script, see that you have used a window event handler (window.onfocus) twice. Try first:

    Rename in the second functions those variables with common name.

    Use a single event handler

    window.onfocus = close;
    function close(){
    CloseTWWin;
    CloseTW2Win;
    }
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •