I have a text box where the user enters their employee email address. What I want to occur is when the @ sign is pressed it will automatically add the rest (ie. mycompany.com)
I know the code required to alter the value of a text box but I dont know the event trigger or code to detect the keypress.
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?
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.
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).
I am trying to pop up a window and then do stuff(set flags) when the content of the new window is done loading. For this I am trying to detect the window.onload of the pop-up child window but so far I am unsuccessful. I believe my problem is that the URL of child window is on different domain, than the one of the opener(parent) so that the window.onload is not being called. Though this may change, at the moment I do not have access to the code for the page I'm opening up in the pop-up. Im pretty new to web development.
Is there any way to detect the width of the window in which a page is displayed? I know how to detect the screen width, but that only helps if the page is always maximized.
I know 800x600 screens occupy a shrinking part of Web surfers, but I want to accommodate them by offering an alternate style sheet where my site pages don't break when someone from this smaller group visits. Yes, there are examples of how to do this on the Web, but I have one more requirement and don't know how to code it. Not only do my pages break on 800x600, they also break if the browser widow is sized smaller on a 1024x768 screen. (I'm studying css that will dynamically respond to this but I'm not there yet.) Do I just need an appropriate if/or statement to deliver different style sheets? Is there even a JS that detects browser window changes?
So, basically, I need to detect whether an alert window was thrown. I can't find where it's thrown from but I need to disable a button only if there were no alert windows thrown.
I have been working on this problem all day. I have several pictures on a page. When a user clicks it, a popup window will show up a series of pictures. Inside the popup window, there is a close icon to turn of the popup. Besides, if the user clicks outside of the popup, the popup will turn off as well. Here is what I have so far.The closed icon inside the popup works fine but I can't get "the click outside of the popup" to work.
I want to detect when the window is moved, in order to trigger something. I have managed to get the current X and Y coordinates, but other than checking periodically for changed coordinates, is there a way to do this? I want to be able to trigger the code pretty instantly when the window is moved. Probably not possible without checking every half a second - this would be too cpu intensive right?
I'm working on a website, where a fixed <div> holds the menu and links id's on the page with <a href="#">'s - like this:
HTML Code:
I'm wondering if it's possible to detect which of the <h1 id="i1">Item1</h1>'s that's currently shown on in the browser window? My idea is to highlight the menu-link(s) (e.g. by changing color) of the items headings shown in the browser window (so it changes as the user scrolls down through the page)?
i would like to check for the window size with jquery and based on the different resolutions i would like to change the background image. So i was thinking to somehow use the "switch" statement for more cases, but i just don't know how this would look like. This is the basic structure i want but with more options:
if ((screen.width>=1024) && (screen.height>=768)) { //do something }
I'm relatively new to jQ and would like to determine if a named window is already open. If it is then I want to change focus to that window/tab. The scenario is this. I have a link in App1 that opens a new window to an already existing linked (related) web form in App2. If the user forgets they have that window open in App2 and clicks the same link in App1 as before (to open the related form in App2,) it opens a window that is not the same window as the original window. I need App1 to detect if a window already exists in the browser of the same name and if so, change the browser focus to it.
Can Javascript be used to detect a certain url and then "not" write some html according to that url and also detect something on the page and "then" display some html?.
Example: I'm working on a volusion site that uses asp. There's basically only one page that's changed dynamically. I would like to display some html when and only if the cart has any items in it. But also not to show up on the check-out pages.
The page dynamically displays "Your cart has 1 item in it..." when the visitors puts something in their cart.
So could javascript detect when this is displayed then write some html and then also detect if the url is showing the cart and then not show the html?
I have read all posts about how to detect that url have changed to new page and trigger the event handler then eg.
function aidLogout(evt) { if(evt) { /* maybe via analyse of evt object i can detect the close of the browser window */ } if(window.event) { /* maybe via analyse of window.event object i can detect the close of the browser window */ } var i = new Image(); i.src = "aidlogout.asp?uid=1562&SessionID=ABCDEFGHIJKLMNOP" } /* assuming that aidlogout.asp will return nothing or empty image */
window.unload = aidLogout; /* or via if(window.addEventListener) { window.addEventListener("unload", aidLogout, false); } else if(window.attachEvent) { window.attachEvent("unload", aidLogout); }
PS i know about super Gecko onclose event which fires when browser window is closed, but i could not find such method in IE.
As the subject says it, is there a way to simulate a special keypress in JS ? In my case, on loading an HTML page, i'd like to set the cursor at the end of the input text of an <input type=text ...> object. focus() sets the cusor at the beginning Any idea ?
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.