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 4 of 4

Thread: focus(); help

  1. #1
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    focus(); help

    I have a small site that acts as a toolbar for a txt based RPG. Its got countdown timers on it for various aspects of the game. I had always used the alert() box to advise people when the timer had expired.

    I decided I wanted to customize the alert boxes. So far I got it to work, but I can't figure out how to get the script to bring focus back to the window/frame. The "alert" pops up. Just won't focus to that window. Any help would be appreciated.

    This is the actual toolbar code(toolbar.html). Theres an index.html that is framed to have the toolbar at the top and game window at the bottom. If you need that code I can post it as well.

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    
    <head>
    
    <LINK HREF="style.css" TYPE="text/css" REL="stylesheet">
    <title>The Agency BETA Toolbar</title>
    
    <base target="main">
    <base href="http://www.mafiareturns.com/">
    
    <script type="text/javascript">
    function showHide(layerid){
    if (document.getElementById(layerid).style.visibility != "hidden"){
    document.getElementById(layerid).style.visibility = "hidden"
    }
    else{
    document.getElementById(layerid).style.visibility = "visible";
    
    }
    }
    </script>
    
    </head>  
      
    <body>
    
    <DIV id="pettytimer" 
    
    style="position:absolute;right:10;top:10;width:250;height:60px;color:#FFFFFF;border-top:2px solid #ffffff; 
    
    border-left:2px solid #ffffff; border-right:2px solid #808080; border-bottom:2px solid #808080; 
    
    background:#d8cfc8;visibility:hidden;text-align:center;">
    <div style="height:14;font-size:12;text-align:left;color:#00CC33;">Petty Timer</div>
    <div style="color:black;height:25px">Lets go steal that ladies Purse</div>
    <button style="width:74;height:15;font-size:9;border:1px outset #ffffff;" onclick="showHide('pettytimer'); 
    
    parent.main.location.href='http://www.mafiareturns.com/profit/pettycrime.php'">OK</button>
    </DIV>
    
    <DIV id="felonytimer" style="position: absolute;right: 10;top: 10;width:250;height: 60px;color: 
    
    #FFFFFF;border-top: 2px solid #ffffff;border-left: 2px solid #ffffff;border-right: 2px solid 
    
    #808080;border-bottom: 2px solid #808080;background: #d8cfc8;visibility: hidden;text-align: center;">
    <div style="height: 14;font-size: 12;text-align: left;color: #3333FF;">Felony Timer</div>
    <div style="color:black;height:25px">Felony Timer Expired</div>
    <button style="width:74;height:15;font-size:9;border:1px outset #ffffff;" onclick="showHide('felonytimer'); 
    
    parent.main.location.href='http://www.mafiareturns.com/profit/felony.php'">OK</button>
    </DIV>
    
    <DIV id="flighttimer" 
    
    style="position:absolute;right:10;top:10;width:250;height:60px;color:#FFFFFF;border-top:2px solid #ffffff; 
    
    border-left:2px solid #ffffff; border-right:2px solid #808080; border-bottom:2px solid #808080; 
    
    background:#d8cfc8;visibility:hidden;text-align:center">
    <div style="height:14;font-size:12;text-align:left;color:#474747;">Flight Timer</div>
    <div style="color:black;height:25px">Pack your bags, its time to go</div>
    <button style="width:74;height:15;font-size:9;border:1px outset #ffffff;" 
    
    onclick="showHide('flighttimer')">OK</button>
    </DIV>
    
    <DIV id="wacktimer" 
    
    style="position:absolute;right:10;top:10;width:250;height:60px;color:#FFFFFF;border-top:2px solid #ffffff; 
    
    border-left:2px solid #ffffff; border-right:2px solid #808080; border-bottom:2px solid #808080; 
    
    background:#d8cfc8;visibility:hidden;text-align:center">
    <div style="height:14;font-size:12;text-align:left;color:#FF0000;">Wack Timer</div>
    <div style="color:black;height:25px">Who's next to die</div>
    <button style="width:74;height:15;font-size:9;border:1px outset #ffffff;" 
    
    onclick="showHide('wacktimer');">OK</button>
    </DIV>
    
    <table width="100%" align="left" border="0">
    <tbody><tr>
    
    
    <td width="14%" valign="top" align="center">
    <DIV CLASS="headerstyle">News and Info</DIV>
    <a href="news/obits.php">Obits</a><br>
    <a href="news/personals.php">Personal</a><br>
    <a href="news/local.php">Locals</a><br>
    <a href="news/search.php">Search</a><br>
    <a href="http://www.outerrealm.org/mafia/beta/changelog.txt" target="_blank"><i>Log</a> /<a 
    
    href="http://www.outerrealm.org/mafia/Beta/source.php?file=toolbar.php" target="_blank"> Source</i></a><br>
    </td>
    
    
    <td width="14%" valign="top" align="center">
    <DIV CLASS="headerstyle">Management</DIV>
    <a href="manage/airport.php">Airport</a> /
    <a href="manage/bank.php"> Bank</a><br>
    <a href="manage/profile.php">Profile</a> /
    <a href="manage/passwd.php"> Change PW</a><br>
    <a href="war/jail.php">Jail</a><br>
    <a href="manage/crew.php">Crew</a> /
    <a href="manage/hq.php"> Buy HQ</a><br>
    <a href="graveyard.php">Graveyard</a>
    </td>
    
    
    <td width="14%" valign="top" align="center">
    <DIV CLASS="headerstyle">Profit</DIV>
    <a href="profit/pettycrime.php">Petty</a> / 
    <a href="profit/felony.php">Felony</a><br>
    <a href="profit/drugs.php">Drugs</a><br>
    
    <DIV CLASS="headerstyle">War</DIV>
    <a href="war/wack.php">WACK!</a> /
    <a href="war/hitlist.php"> Hitlist</a><br>
    <a href="war/mug.php">Mug</a> /
    <a href="war/auth.php">Get Auth</a>
    </td>
    
    
    <td width="14%" valign="top" align="center">
    <DIV CLASS="headerstyle">Forums</DIV>
    <a href="comm/forum/announcements.php">Announcements</a><br>
    <a href="comm/forum/street.php">Street</a> /
    <a href="comm/forum/ooc.php"> OOC</a><br>
    <a href="comm/forum/bar.php">Bar</a> /
    <a href="comm/forum/hq.php"> HQ</a><br>
    <a href="comm/suggestions.php">Suggestions</a><br>
    <a href="comm/forum/help.php">Help</a> /
    <a href="comm/chat/index.php" target="_blank"> Chat</a><br>
    </td>
    
    
    <td width="11%" valign="top" align="center">
    <DIV CLASS="headerstyle">Mail</DIV>
    <a href="comm/mobmail.php">Inbox</a><br>
    <a href="comm/sndmsg.php">Create/Send</a><br>
    
    <DIV CLASS="headerstyle">Misc.</DIV>
    <a href="help/bible.php">Bible</a> /
    <a href="http://www.outerrealm.org/mafia/drugtable/" target="popup" 
    
    onclick="window.open('http://www.outerrealm.org/mafia/drugtable/', 'popup', 'width=535px,height=275px'); 
    
    return false"> Drug Table</a><br>
    <a href="http://www.outerrealm.org/imagehost" target="_blank">Images</a> / <a 
    
    href="http://www.outerrealm.org/mafia" target="_blank">@</a> / <a href="vote.php?link_id=1" 
    
    Target="_blank">Vote</a>
    
    
    </td>
    
    <td width="16%" valign="top" align="center" style="background-image: 
    
    url(http://www.outerrealm.org/mafia/original/logo2.jpg); background-repeat: no-repeat; background-position: 
    
    bottom;">
    
    
    <div class=timerheader>Travel</div> <a class="timers" href="javascript:setflight()" target="_self">
    <span id="airtim"></span></a> <a class="reset" href="javascript:maReset(2)" target="_self">RESET</a>
    <br>
    
    <div class=timerheader>Wack</div> <a class="timers" href="javascript:setwack()" target="_self">
    <span id="watim"></span></a> <a class="reset" href="javascript:maReset(4)" target="_self">RESET</a>
    <br>
    
    <div class=timerheader>Felony</div> <a class="timers" href="javascript:setfelony()" target="_self">
    <span id="feltim"></span></a> <a class="reset" href="javascript:maReset(3)" target="_self">RESET</a>
    <br>
    
    <div class=timerheader>Petty</div> <a class="timers" href="javascript:setpetty()" target="_self">
    <span id="petim"></span></a> <a class="reset" href="javascript:maReset(1)" target="_self">RESET</a>
    
    
    
    
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    		var maPetty=(0); var maFly=(0); var maFelony= (0); var maWack=(0);
    		refreshID=setInterval("maRefresh()",1000);
    		
    		function maInitialize() {
    		warning.innerHTML=maHeader;
    		main.style.visibility="visible";
    		maRefresh();
    		}
    		
    		
    		function maReset(mType) {
    		if (mType==1) { maPetty=(3.5*60); };
    		if (mType==2) { maFly=(120*60) };
    		if (mType==3) { maFelony=(12*60); };
    		if (mType==4) { maWack=(60*60); };
    		
    		
    		}
    		
    		function maRefresh() {
    		
    		maPetty=maPetty-1; maFly=maFly-1; maFelony=maFelony-1; maWack=maWack-1;
    		
    		
    		
    		var mTm=parseInt(maFly/60);
    		var mTh=parseInt(mTm/60);
    		var mTs=parseInt(maFly-(mTm*60));
    		mTm=parseInt(mTm-(mTh*60));
    		
    		if(maFly <=0){
    document.getElementById("airtim").innerHTML="Flight Time!";}else{
    document.getElementById("airtim").innerHTML = "<div class=countdown>"+mTh+"h:"+mTm+"m:"+mTs+"s</div>";
    	    }
    	    if(maFly ==0){
    	    showHide('flighttimer');
    	    }
    	    
    	    
    	    
    	    var mWm=parseInt(maWack/60); 
    	    var mWs=parseInt(maWack-(parseInt(maWack/60)*60));
    	    
    	    if(maWack <=0){
    document.getElementById("watim").innerHTML="Wack Time!";}else{
    document.getElementById("watim").innerHTML = "<div class=countdown>"+mWm+"m:"+mWs+"s</div>";
    	    }
    	    if(maWack ==0){
    	    showHide('wacktimer');;
    	    }
    
    
    
    
    	    var mPm=parseInt(maPetty/60); 
    	    var mPs=parseInt(maPetty-(parseInt(maPetty/60)*60))
    	    
    	    if(maPetty <=0){
    document.getElementById("petim").innerHTML="Petty Time!";}else{
    document.getElementById("petim").innerHTML = "<div class=countdown>"+mPm+"m:"+mPs+"s</div>";
    	    }
    	    if(maPetty ==0){
    	    showHide('pettytimer');}
    
    	    
    
    
    
    	    var mFm=parseInt(maFelony/60);
    	    var mFs=parseInt(maFelony-(parseInt(maFelony/60)*60));
    	    
    	    if(maFelony <=0){	     	    
    document.getElementById("feltim").innerHTML="Felony Time!</timers>";}else{
    document.getElementById("feltim").innerHTML = "<div class=countdown>"+mFm+"m:"+mFs+"s</div>";
    	    }
    	    if (maFelony ==0){
    	    showHide('felonytimer');}
    	    } 
    	    
    	    function setflight() {
    	    var petim=prompt("Minutes Until You Can Fly Again:",parseInt(120));
    	    maFly=petim*60;
    	    }
    	    function setwack() {
    	    var petim=prompt("Minutes Until You Can kill Again:",parseInt(60));
    	    maWack=petim*60;
    	    }
    	    function setfelony() {
    	    var petim=prompt("Minutes Until You Can Commit Felony Again:",parseInt(12));
    	    maFelony=petim*60;
    	    }
    	    function setpetty() {
    	    var petim=prompt("Minutes Until You Can Commit Petty Crime Again:",parseInt(3.5));
    	    maPetty=petim*60;
    	    }
    // -->
    </SCRIPT>
    
    </td></tr></tbody></table>
    
    <script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
    </script>
    
    <script type="text/javascript">
    _uacct = "UA-902302-1";
    urchinTracker();
    </script>
    
    </body></html>
    Thanks in Advance.

    Jian

  • #2
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    anyone? any ideas?

  • #3
    Senior Coder
    Join Date
    Nov 2006
    Posts
    1,000
    Thanks
    0
    Thanked 0 Times in 0 Posts
    So you are trying to get the button to have focus?

  • #4
    Senior Coder
    Join Date
    Nov 2006
    Posts
    1,000
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I tried this

    Code:
    function showHide(layerid){
      if (document.getElementById(layerid).style.visibility != "hidden"){
        document.getElementById(layerid).style.visibility = "hidden"
      } else{
        document.getElementById(layerid).style.visibility = "visible";
        document.getElementById(layerid + "button").focus();
      }
    }
    and added and id to each button like id="flighttimerbutton"

    Code:
    <button id="flighttimerbutton" style="width:74;height:15;font-size:9;border:1px outset #ffffff;" onclick="showHide('flighttimer')">OK</button>
    david_kw


  •  

    Posting Permissions

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