Open new window on keypress is only working in Opera

  • tiffix
  • Student
  • Student
  • User avatar
  • Joined: Jun 03, 2009
  • Posts: 65
  • Loc: kenya
  • Status: Offline

Post March 9th, 2011, 8:01 am

Hello,
i have the following code which only works in opera. help me get it to work with other browsers. thanks
Code: [ Select ]
<script type="text/javascript">
                    function respondToKey(e) {
                    keyPressed = String.fromCharCode(e.which);
                    if(keyPressed == 'g'){
                        window.open('http://localhost/gith/index.htm','mywindow','width=400,height=200');
                    }
                }
        </script>
  1. <script type="text/javascript">
  2.                     function respondToKey(e) {
  3.                     keyPressed = String.fromCharCode(e.which);
  4.                     if(keyPressed == 'g'){
  5.                         window.open('http://localhost/gith/index.htm','mywindow','width=400,height=200');
  6.                     }
  7.                 }
  8.         </script>


Code: [ Select ]
<div id="footerkeywords" onkeypress="respondToKey(event)"></div>
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post March 9th, 2011, 8:01 am

  • spork
  • Brewmaster
  • Silver Member
  • User avatar
  • Joined: Sep 22, 2003
  • Posts: 6134
  • Loc: Seattle, WA
  • Status: Offline

Post March 9th, 2011, 11:37 am

It would help if you told us what it's supposed to do and what is happening in other browsers.
The Beer Monocle. Classy.
  • Bogey
  • Bogey
  • Genius
  • User avatar
  • Joined: Jul 14, 2005
  • Posts: 8212
  • Loc: USA
  • Status: Offline

Post March 9th, 2011, 9:36 pm

I think I can decipher what it's supposed to do... I think he wants to add shortcuts to his site, like when "g" is pressed the user would be sent to this page, and if "h" is pressed then the user would be sent elsewhere... as to how to get that and what is happening in other browsers, I have no idea.
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
  • tiffix
  • Student
  • Student
  • User avatar
  • Joined: Jun 03, 2009
  • Posts: 65
  • Loc: kenya
  • Status: Offline

Post March 9th, 2011, 11:04 pm

Bogey is correct. and the pop-up window is open in opera but when i check with other browsers it is not opening. the pop-up window should open when i press 'g' anywhere within the <div id="footerkeywords" onkeypress="respondToKey(event)">Press 'g' to open pop up window...</div>

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 115 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.