Call Window.open() From A Keypress Event?

Nov 11, 2007

I've got a script which is called by a keypress event, something like this:

<html>
<head>
<script type="text/javascript">
function respondToKey(e) {
keyPressed = String.fromCharCode(e.which);
if(keyPressed == 'g'){
alert('you pressed the g key');
window.open('http://google.com');
}
}

</script>
<title>Untitled</title>
</head>
<body onkeypress="respondToKey(event)">
hit the g key to open a google window
</body>
</html>

when you hit the right key, the alert appears, but the window.open() never happens. There's not even a message in the Error Console, just nothing.

Is this a security feature? Any way I can get around it? And, if it's a security feature, is the fact that it fails silently with no error message also a security feature? Because it's rather annoying.

View 2 Replies


ADVERTISEMENT

Child Window Close Event - Opening Another Link In A Separate Window Using Window.open()

Jan 29, 2010

I have a HTML and I am opening another link in a separate window using window.open() . The child window is something like 'http://yahoo.com' which is out side html. I need to refresh the parent window when the child window is closed.

View 4 Replies View Related

Window.open, How To Call From Link/button

Feb 10, 2001

I have the code worked out, I just need to know how to call it from a hyperlink on an existing page. The code is as follows:

<script>
window.open('http://www.mysite.net/chat.htm', 'DummyName', 'height=350,width=520', false);
</script>

This works fine on a page by itself, but it opens the "chat.htm" page, as well as one before it that runs the code. It would be much better to just run it from a hyperlink button from the main page and not load the first unnecessary page in the first place.

View 4 Replies View Related

JQuery :: Why PreventDefault At Keypress Event Prevent The Change Event

Aug 13, 2011

look at this script :

$(function(){
$('input').bind('keypress',null,b).bind('change',null,a);
});
function a(){

[Code].....

this script bind both keypress and change of the text box to functions b and a. at keypress event handler if user type a char on input box the value of input box change to x and the user char discarded. In this case we expected to run the onchange (change) event because the textbox value is changed BUT this doesn't happen.

View 1 Replies View Related

JQuery :: Call A Method From Current Class Using Keypress ?

Mar 30, 2011

I have the following code in one of my pages. My problem is caused, because the method "processEvent" is never called, but I have no idea why. I guess it is broken, because I don't relay the "this" object correctly.

<script type="text/javascript">
var MyClass = function()
{
this.init = function()

[Code].....

View 1 Replies View Related

Which Event Should Be Used To Call Logout On Window Close And Url Change?

Oct 7, 2009

Which javascript event should be used to call logout on window close and url change.
I want to call logout function on window close and URL change on my application.

I am calling logout functionon on <body onunload="doLogout();">, but onunload event is also called when refreshing the page. is there any specific event for Windoe close and URL change.

View 4 Replies View Related

Keypress Event In DOM?

Jun 18, 2003

DOM2 does not provide a key event module. (http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html#Events-eventgroupings-keyevents) That's fine. I'm down with that.

According to the DOM3 Events spec (http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/events.html#Events-KeyboardEvents-Interfaces) (in last call), there's no keyPress event, only keyDown and keyUp. Instead (I guess) they've defined a new interface for text events (http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/events.html#Events-TextEvent), which provides one event type: textInput.

Should I not code event handlers for keyPress events if I wish to write DOM-compliant scripts? IE & Moz both register a keyPress; I'm sure that it won't be outphased. I worry instead about a new and better browser appearing and balking on my script because it's coded exactly to spec.

View 1 Replies View Related

On List Box Change Event Open New Url In Current Window

Jul 20, 2005

How do I on the change event of a list box open a new url in the current window in which the list box resides. I'm not using frames.

View 2 Replies View Related

Getting Keycode From Keypress Event

Jul 20, 2005

I have:
<div onkeypress="go(event)">...</div>
and:

function go(event) {
alert(event.keyCode);
}

but I always get 0 for the keycode.

View 3 Replies View Related

Dynamic Assign Keypress Event

Jul 25, 2006

Hi have an event called function allownumberonly(evt);

My html text input onkeypress calls this function.
onkeypress=allownumberonly(event)

I want to create a text input dynamically and set its onkeypress event
to the above function also passing the event.

View 1 Replies View Related

Click Event - Mouse Or Keypress

Sep 1, 2007

Is there any cross-browser method of determining whether a click event was triggered by a mouse left click or the keyboard's 'enter' key? I was expecting event.button, or event.which to be able to do this, but this doesn't seem to be the case. Checking event.clientX == 0 && event.clientY == 0 works in FF, but not in IE.

View 1 Replies View Related

Adding Keypress Event To List Box?

Jun 25, 2009

i am using asp.net listbox and want to add double click & keypress(enter) key event

i amuisng

function lstDblClicked()
{
for (var i = 0; i <document.Form1.lst_name.options.length; i++)
{

[Code].....

View 1 Replies View Related

Override A Keypress Event And Redirect It To Another?

May 6, 2010

Code...

I'm getting an error object required on the window.onkeypress line.

I have a data entry app and the users are keying with their right hand on the number pad and flipping pages with their left. If they want to use the normal tab key they have to take their hand off of the papers to do so. I figured it would be pretty simple to override the keypress even for the + key and divert it to act like tab was pressed instead.

View 3 Replies View Related

Jquery :: Trigger Event With Keypress?

Jul 13, 2010

I am trying to run some code if a series of keypresses the user types is equal to the correct series of keypresses.I know how to do this if I am just trying to get one keypress. But what about one after another?

View 2 Replies View Related

Detect Keypress In Window

May 12, 2010

Is there any way to detect a key being pressed in the window? I have tried the following but it doesnt work:

document.onkeyup = KeyCheck;
function KeyCheck()
{
var keyID = event.keyCode;
alert(keyID )
}

View 3 Replies View Related

Problem With Html Page Using Cached Page In Window.open(url) Call

Jul 20, 2005

I have an html page that uses javascript to open a new window and
display a file that gets created when a button is pressed.

My problem is when the file is changed and the display button is
pressed, the old file is still displaying. I have tried using

<META HTTP-EQUIV=expires CONTENT=0><META HTTP-EQUIV=PRAGMA CONTENT=NO-CACHE>, but doesn't work 100% of the time.

View 1 Replies View Related

Chrome Not Firing Window.addEventListener Keypress

Aug 20, 2010

On my site we have image galleries that pop up over top of the page in a higher z-index and position:fixed, and another div between the gallery and background with opacity set to about 85%. The image gallery div has a close button, and I was asked to make the gallery also close by pressing ESC, so I added this:

igevt=function(evt){checkclosegal(evt)}
window.addEventListener('keypress',igevt, false)
and checkclosegal:
function checkclosegal(evt)

[Code]....

This works perfectly in Firefox and Opera, but Chrome and Safari don't fire the event (not worried about ie right now - I know it uses attachEvent). Could it have something to do with the gallery being in a higher z-index?

View 3 Replies View Related

Chrome Not Firing Window.addEventListener Keypress?

Aug 20, 2010

On my site we have image galleries that pop up over top of the page in a higher z-index and position:fixed, and another div between the gallery and background with opacity set to about 85%. The image gallery div has a close button, and I was asked to make the gallery also close by pressing ESC, so I added this:

igevt=function(evt){checkclosegal(evt)}
window.addEventListener('keypress',igevt, false)
and checkclosegal:
function checkclosegal(evt)

[Code]....

This works perfectly in Firefox and Opera, but Chrome and Safari don't fire the event (not worried about ie right now - I know it uses attachEvent).

View 2 Replies View Related

Code - Void Window.open - Link Would Open In The Same Window?

Feb 7, 2009

I have this piece of code which is opening link in new window:

How to change this code so link would open in the same window?

Probably I should change this part: javascript:void window.open

View 1 Replies View Related

JQuery :: Making Call On BeforeSend Event Of Another Call?

Apr 30, 2010

I need to make a $.post call on the beforeSend event of another $.ajax call.I read the documentation and I see that if the beforeSend return false the ajax call will be interrupt.So I made this code but doesn't work, because the real value of the beforesend function isn't true or false, is the value of the post.I have to do this because when you click on a link I need to verify before if you are able to do this via db permission of my webapp.I think you don't understand...This is the code:

$.ajax({
async: true,
beforeSend: function(){[code]....

});I see always the alert of success event, so the return of the beforesend is not correctly done.

View 3 Replies View Related

Links That Uses Window.open Then Open A New Designated Window

Jan 17, 2012

I have a problem on the links on my page im working.sorry guys still a noob and my english is not that good. :b. my question is like i have a list of packages of food. [link_a] [link_b] [link_c] and i have a function that i put in my head tag:

function linkA()
{
window.open('link_a.html','link','width=300,height=200,resizable=yes');
}

now i can go to linka.html by click my link <A HREF="javascript:linkA()" >link a</A> is there a way i can have one functions that can open a link depend on what page .when it clicks then go to its designated page or i have to stick on writing function for linkB ,C,D and so on.

View 7 Replies View Related

Open A Link On The Same Window Using Window.open Or Any Other Method?

Oct 19, 2011

How to open a link on the same window using window.open or any other method in JavaScript.

View 2 Replies View Related

Open In New Browser Window (like With Target="_blank", Not Window.open)

Dec 1, 2011

Code: window.location but have it open in new browser window (like with target="_blank", not window.open)

View 7 Replies View Related

Thru Window.open Open A Word Document In Print Preview Mode

Jul 23, 2005

Through window.open or window.showmodaldialog, I want to open a word
or excel document in Print Preview mode. Bcos I don't want the user to
make any changes or save it but the user can ONLY VIEW OR take a print
out.

View 1 Replies View Related

Window.Open In FireFox - Click Very Quickly - Multiple Windows Open

Nov 16, 2009

I'm using an <A> tag with an onclick event to open a window with JS (window.open)... In FIREFOX, if I click very quickly, multiple windows open. Not a problem in IE.

View 8 Replies View Related

JQuery :: OnChange Event - Web Application - Each Blur Event Makes A Call Webserver To Store Value Of Textfield

Jan 21, 2010

I'm currently facing a weird issue with the onchange event. I have a web application where each blur event makes a call the webserver to store the value of the textfield. I only want to trigger that ajax call when something has changed, so i track the onchange event on each textfield to set a flag if something has changed.

The onchange event always fires to first time when i click outside of a textfield even if i didn't change anything in the field.

I narrowed it down to the following: A prefilled textfield always fires the onchange-event the first time you leave the textfield. An initially empty textfield does not fire the onchange event.

Sample code (IE 8 on Windows 7 computer):

script:

HTML:

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved