i have a form made up of 2 file inputs and a submit button.. the imputs are to upload images, namley jpeg's for a e-greatings thing im working on.
this only works with jpegs so i have a script that will check the value of the imput tag to make sure it ends with .jpg, .jpeg.
this works fine on the jubmit button using
onclick="myHandler(this)"
it works fane that it alerts the user that only jpegs are valid but then when the alert has been ok'd it continues to submit the form to my php script.
I have two javascript onloads in my form which seem to be cancelling each other out. The first- onload="checkMyBox"- works fine, which means the calendar stays hidden until the ckeckbox is clicked. However the second script that is supposed to show text ("I am an organized person") only after image is clicked does not work. It always shows the text.
I tried playing with it, and realized that if I erase the first <body onload="checkMyBox('c2','div1')"> the second onload works, meaning that the text will stay hidden until I click on image.
Code JavaScript: <script type="text/javascript"> function checkMyBox(trigger,toggled){ var mcb = document.getElementById(trigger); var cal = document.getElementById(toggled);
I am displaying my own context menu in response to a right-click on control (textbox) in my ASP.NET application. In IE, I can suppress the display of the browser's own context menu by simply returning false from the javascript that displays my context menu.How can I suppress the browser context menus from Chrome or Firefox?
Im writing a small app that will basically be like a wiki for family memebers to go in and make pages using my wysiwyg editor, update pages, ect..
the problem i've run into is trying to ensure they have saved the page. I have a variable to detect whether or not unsaved changes exist. however the problem is now stopping the close event if the user clicks 'cancel' in the confirmation box.
Examples of when the 'navigation' or 'browser close' should be blocked: 1)i've made a small change on the page then clicked on a link, i should receive a conf message asking me if i want to loose changes. 2)i've made a change on the page then clicked the browser 'X' (close) button by accident. I should get the conf message here as well. 3) i've hit the refresh or reload button without saving. again i want the conf message.
Note, if they want to close, clicking OK should allow them too. furthermore, this function to block the close and produce the confirmation only will be called if there are unsaved changes on the page.
here is what i have so far - and this appears to work fine in IE. Code:
I am trying to "ajaxify" my site. Now I have one problem:
$("#posts").children().remove(); $("#tag-sidebar").children().remove(); $.each(data.Tags_Sidebar, function (indexInArray, valueOfElement) { var insert = $("<li>");
[Code]......
Now when I click one of those links (href1, href2, href3) generated, the click event won't execute! What's the problem? Also, is it right that I have to transfer the valueOfElement over, like I did? What does stopEventPropagation do? Prevent the href from being navigated to? That's what I am trying to do.
I have a series of images with an animation bound to mouseover and mouseleave events, and I'm trying to get my head around adding a click event that would prevent the mouseleave animation from occurring only for the image that was clicked, preserving everything else as is (until another image is clicked). I've discovered .stop() and I think I'm getting close, but some part of the logic is still escaping me.
I've got 2 pages: a current events page and a past events page the current events page loads fine as there is only about 10 events the past events page takes about 30 seconds to load and will crash if u click your mouse in the loading time.
The pages are near identical the only difference is the query that selects the events (> versus <)
The page loads immediately without:
But when i put it back in the above happens. I'm using jQuery.roundedcorners.
The click event will fire if you click the <a>, OR if you tab to it with your keyboard and hit Enter.My question is: is there a way to make elements other than <a> tags accessible in this way? I recently discovered if you define a tabindex on your div, such as <div tabindex="0">test</div>, you can tab to that div, but click events don't seem to fire if you use your keyboard. Are <a> tags the only tags that can work in this way?
This works wonderfully in Firefox, but when it runs for the first time in IE it only creates the field, but won't create any attributes for the events. When debugging the events are null. How can I get this to work in IE. Code:
I am currently creating a small user object that will control some events which will be passed and store some data such as point values. Currently I am having some difficulties with the event method handleMouseDown with any property defined in the object. Code:
I have a general question regarding events. I have a container div, and many divs within it. Without attaching an event to each of the divs, can i attach an event to the container div, and somehow attain which div within it was the event fired over.
I am following the standards, and also do not to need to be concerned about IE, and its issues.
I'm having some difficulties with a menu I'm making. I build up the menu through DOM. I append childnodes to a tree. 2 types of children are possible: url (a hyperlink) and sub (a submap).
The tree is thus of a structure
main |-url1 |-url2 |-submap |--url21 |--url22
To open up the submaps I set the onclick event to a function I created:
itemnode.onclick=function() { openMap(itemnode) }
The problem now is that 1 click in a submap results in several times the openmap function. A click on the url21 node is in fact a click on a child of submap so the function in the onclick event of this submap is called. But it is also a click on a child of main, so this onclick function is also called.
How can you limit that the onclick event handler is only called on the 1 node (ic. submap) where you actually clicked on submap instead of its urls?
I want to make my site more dynamic... but i dont find out how this works...
On my site there is at the left side the navigation bar and at the rigt side i want to put a photo. The photo should change when someone puts the cursor over the links in the left side.
I'm doing a tutorial from a book to drag and drop elements on a page into a shopping cart. I had everything working fine in IE until I added the function for key presses. What it should do is when 1 is clicked, the first item is moved into the cart, and if I press 1 again the item goes back to where it started.
The function that's giving me problems is keyDrag (at the bottom). I included the other functions in case you need to see them because keyDrag calls them. The error I'm getting in IE is "object expected" and it's at the line marked below in the keyDrag function.
What happens when I press 1 is the item that's supposed to go to the cart appears at the cursor as if I clicked and dragged it. But if I drag it manually into the cart, and then press 1, it will snap back to its original place without problems.
I'm just not getting how to script for events. I know it's a heavy task, but would somebody be willing to break it all down for me? I'd really like to learn these. Code:
This simple program displays the Keycode & event type for a key pressed. Good for a quick reference.
<html> <head> <title>Keyboard Events and Codes</title> <style type="text/css"> body {font-family:Arial, sans-serif} h1 {text-align:right} td {text-align:center} </style> <script language="JavaScript" type="text/javascript"> // array of table cell ids var tCells = ["downKey", "pressKey", "upKey", "downChar", "pressChar", "upChar", "keyTarget", "character"];
// clear table cells for each key down event function clearCells() { for (var i = 0; i < tCells.length; i++) { document.getElementById(tCells[i]).innerHTML = "—"; } }
// display target node's node name function showTarget(evt) { var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null); if (node) { document.getElementById("keyTarget").innerHTML = node.nodeName; } }
// decipher key down codes function showDown(evt) { clearCells(); evt = (evt) ? evt : ((event) ? event : null); if (evt) { document.getElementById("downKey").innerHTML = evt.keyCode; if (evt.charCode) { document.getElementById("downChar").innerHTML = evt.charCode; } showTarget(evt); } }
// decipher key press codes function showPress(evt) { evt = (evt) ? evt : ((event) ? event : null); if (evt) { document.getElementById("pressKey").innerHTML = evt.keyCode; if (evt.charCode) { document.getElementById("pressChar").innerHTML = evt.charCode; } showTarget(evt); var charCode = (evt.charCode) ? evt.charCode : evt.keyCode; // use String method to convert back to character document.getElementById("character").innerHTML = String.fromCharCode(charCode); } }
// decipher key up codes function showUp(evt) { evt = (evt) ? evt : ((event) ? event : null); if (evt) { document.getElementById("upKey").innerHTML = evt.keyCode; if (evt.charCode) { document.getElementById("upChar").innerHTML = evt.charCode; } showTarget(evt); } }
// set page-wide event listeners document.onkeydown = showDown; document.onkeypress = showPress; document.onkeyup = showUp; </script> </head> <body> <h1>Key and Character Codes vs. Event Types</h1> <hr> <p>Enter some text with uppercase and lowercase letters:<br> <form> <input type="text" id="entry" size="60" onkeydown="showDown(event)" onkeypress="showPress(event)" onkeyup="showUp(event)"> </textarea></p> </form> <table border="2" cellpadding="5" cellspacing="5"> <caption>Keyboard Event Properties</caption> <tr><th>Data</th><th>keydown</th><th>keypress</th><th>keyup</th></tr> <tr><td>keyCode</td> <td id="downKey">—</td> <td id="pressKey">—</td> <td id="upKey">—</td> </tr> <tr><td>charCode</td> <td id="downChar">—</td> <td id="pressChar">—</td> <td id="upChar">—</td> </tr> <tr><td>Target</td> <td id="keyTarget" colspan="3">—</td> </tr> <tr><td>Character</td> <td id="character" colspan="3">—</td> </tr> </table> </body> </html>
I am currently working on a website that administers timed online tests, and we are trying to implement some measures to reduce the ability to 'cheat' while the test is running. These include disabling right clicks, and handling keystroke events. Additionally, we would like to end the test if the maximized browser popup window where the test is loaded happens to lose focus during the testing session.
I have implemented some code to call an event handler that will end the test if a window.onblur event is triggered during the session. It is working fine in Firefox, but IE seems to interpret window.onblur events differently. Basically, in Firefox I can click anywhere within the window without a window.onblur event triggering, but in IE if I click outside of the test table or form element etc. into whitespace, for instance, it fires.
In addition to using window.onblur, I have also tried top.onblur, and also putting onblur in the body tag of my html: <body bgcolor="#ffffff" onBlur="lostfocus()"> Again, both work in Firefox, but neither of these alternate methods seem to restrict IE in the appropriate manner.
So my question is this: is there any way to craft this such that IE will play nice and trigger the event ONLY when someone clicks outside of the browser window (on to the start menu, for instance)?
<script language="javascript"> <!-- window.onblur=lostfocus; function lostfocus(e) { // student has attempted to cheat, end test } // --> </script>
How would I write 2 onload events into the body tag?
I currently use:
onLoad="if (self != top) top.location=self.location" and have found a scroller that may work better than my current one but it has an onload command as well.
i have a problem with two occuring events in a form. On a input/text field I have registered an onChange Handler and I have defined a submit Button.
Now the users changes the value of the texfield and hits the enter-Key. Now it seems that both events occures, the onChange and the onSubmit of the form. Can I defined the order of the events or better cancel one event, when the other occurs (e.g. cancel the onChange when the user hits the enter-key)?