OnBlur Events And IE

Jan 5, 2006

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>

View 10 Replies


ADVERTISEMENT

Binding Two Onblur Events?

May 12, 2011

I have a link that has a UL drop down. When I click off of both the link and the UL I want the drop down to disappear. Right now it only disappears after I click off of the link.

Code JavaScript:
allLinks[i].onblur = function()
{

[code]....

View 3 Replies View Related

Events Get Lost (from OnBlur To OnClick)

Oct 5, 2005

*The Situation*
A traditional situation where HTML form inputs are checked...

(if simplified then it would look something like this)

<form onSubmit="return checkWholeForm(this)">
<!-- other inputs -->
<input type="text" name="anInput" onBlur="dataCheck(this, ...)" />
<span id="error_anInput"></span>
<!-- other inputs -->
<input type="submit" name="btnSubmit" />
</form>

dataCheck validates the inputs value and if something is wrong, then..
document.getElementById('error_anInput').innerHTML = 'Error!'
or if data is valid then the content of span is removed.

The checkWholeForm function iterates through all elements on the form
and triggers onblur() for each input... leading to executing function
dataCheck (and so changing innerHTML of some specific span elements if
needed).

*The Problem*
If I have entered incorrect data to an input and hit the submit button
with my mouse (causing the onBlur event to be triggered just right
before onSubmit) then *occasionally* for some fields the onSubmit event
is not triggered because the onClick event is not triggered. :S

As there are actually quite many complex functions (tested and these
seem OK afaik) that are doing the checks then dowes anyboudy have a clue
what type of code might break this. I thought at first that setting
innerHTML to some value during onBlur disables all waiting events but as
this is happening occasionally (on some machines) I'm in doubt...

any ideas what to check? double declaration of function/variable names?
Not deleting some object after usage? ... anything?

Waiting for any ideas...

PS. http://eix.lap.ee/test/portali_js.html in the example *occasionally*
third field generates the error - remove any content from the field
and stright hit the submit (*with mouse* - to create onBlur and onClick
at the same time).

View 2 Replies View Related

Triggering Onblur Events With Return Key

May 30, 2006

I have made many forms that trigger with the onblur event on text boxes, and I want to make it posible to trigger the same events when I hit the enter key but without loosing focus (I know I can call the blur event and trigger the onblur event but I don't want to loose focus). By the way Iam using prototype.js .

View 3 Replies View Related

Onfocus And Onblur Events Don't Work Correctly?

Sep 9, 2009

I have a page with a textbox that I want to have a message written inside it that will dissapear when the user clicks in the text box and writes something and it will show up again if the user clicks somewhere else but hasn't written anything inside the textbox. So I am using the onfocus event in order to write "Enter your email here" and the onfocus event in order to show the "Enter your email here" message inside the textbox if the user clicks somewhere else in the webpage but has left the textbox blank. If however the user has written, for exampl "jim@yahoo.com", I want this to remain in the textbox.What am I doing wrong?

Code:
<html>
<head>

[code]....

View 2 Replies View Related

Calling Parent Onblur Event After Child Onblur Event?

Jul 2, 2009

I am having one td and inside td using one control(it may be any control like textbox,combobox) and am using onblur events for td and aswell as the control inside td. when am moving focus from this td to another td the parent onblur event is firing first and then child control(like textbox, combobox) onblur event is firing. The problem is am validating that entire td (what ever the value user updates) in one method. so in this scenario that validate method is calling when i move the focus onto child control. After entering the value in the child control that child control onblur event is firing and am unable to fire the parent control(td) onblur event.

View 1 Replies View Related

JQuery :: Events Defined In $.each (creating List Elements With Events) Not Executing?

Jul 21, 2010

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.

The data object is JSON fed from here:[URL]

The HTML is here: [URL]

View 2 Replies View Related

JQuery :: Binding Events With Other Events?

Feb 4, 2011

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.

View 3 Replies View Related

OnBlur

Aug 11, 2006

I have two textboxes, each of them is controlled with a function called checknumber. It controlles if they are empty or a valid number and I connected this function to onBlur event of these textboxes. The problem is that when I wrote an invalid number to the first and click the second one, It gives continuously error messages. How can I solve this problem ?

View 6 Replies View Related

OnBlur Madness!

Jul 23, 2005

I'm having trouble with a bit of code that is both validating and updating fields on the fly. Here's something similar to my code:

-----------
<script>
function validate(field) {
var frm = document.theForm;

if (field.value != "") {
frm.field3.value = Number(frm.field1.value) +
Number(frm.field2.value);
} else {
alert("Field is empty.");
}
}
</script>

<body>
<form name="theForm">
Field 1 <input name="field1" type="text" onblur="return
validate(this)">
<br><br>
Field 2 <input name="field2" type="text" onblur="return
validate(this)">

<br><br><br>
Total <input name="field3" type="text">
<br><br>
<input type="button" value="Validate">&nbsp;<input type="button"
value="Cancel" onClick="window.location.href='http://www.google.com'">

-----------

So, I need to

1. Have the "Total" field update whenever a user changes a value in field 1 or field 2.
2. Perform some validation on those fields
3. Have the onblur and validation NOT fire when the user clicks the Cancel button.

Problem: click in the first field, don't enter a value, then try to press Cancel - the validation is happening, and I don't want it to.

This third point above seems to be the kicker. Anyone know a way I can go from a text field to clicking the "Cancel" button without firing the onBlur event? I normally don't like doing validating on-the-fly like this, but my application has the requirement of updating that Total box dynamically, so I have to perform field-level validation as I go....

View 2 Replies View Related

OnBlur Not Working !

Jul 23, 2005

I cannot seem to get these two events to work together. If I change
them to say onmousedown and onmouseup, they seem to work fine. In this
case, the onclick appears to work properly but onblur does not kick
in.

<a href="javascript:submitCheck();"><img border="0" alt="Next"
name="btnNext" src="Resources/SurveyButtons/Next.gif"
onclick="this.src='Resources/SurveyButtons/Wait.gif'"
onblur="this.src='Resources/SurveyButtons/Next.gif'"></a>

Any ideas? am i doing something wrong?

View 5 Replies View Related

OnFocus/onBlur

Jul 23, 2005

For those who have been using Outlook Express, you must be pretty used to
the fact that whenever you focus on the preview section, the header for the
preview turns from grey to blue, while the text turns from black to white.
Code:

View 3 Replies View Related

Handling Onblur

Feb 16, 2006

I have few textfields and dropdowns in my jsp, form is submitted on
clicking an image link.

In case there is an error for instance some text field is left empty,
then message is displayed below respective fields ( using spans, inner
html). The message is displayed onblur event of the field. So if there
was an error then message is displayed, now if the user corrects the
error and clicks the link then first the message disaapears ,which is
desired ,but he has to click again to submit the form. please suggest a
way to handle this. So that user doesn't have to click the link twice
to submit the form.I tried having onmousedown and onfocus events on
image , but then sometimes the form was submitted twice which gave
backend errors.

View 2 Replies View Related

Using OnBlur To Get An Image To Pop Up?

Mar 3, 2010

I am trying to use onBlur to get to pictures to pop up when a user leaves a text box. The only requirement is that a user must enter any value into the text box if they want the pictures to pop up. Unfortunately, I cannot figure out why my code will not work

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

[code]....

View 3 Replies View Related

OnBlur - Getting The Obj That Gets Focus Next

Feb 2, 2008

Supose I have a couple inputboxes, and all have onBlur ---> purpose to evaluate min lenght of text, ... before exiting
input box.

They are all contained inside iFRAME. The onBlur event triggers allso outside iframe, on close browser window, etc
which is unwanted.

1.How to limit onBlur event triggering to objects inside certain IFRAME
2. or..

<input type='text' id='nick' onblur = func(this) ...

function func(obj)
{
// pseudocode - can this be done somehow?
alert(document.getElementById('the next obj that just recived focus'));
}

View 2 Replies View Related

OnBlur Not Working

Sep 25, 2006

I have an JS function called from one of my JSP on Blur on a text box. But the JS function is not being called. I am pasting the code below.

<td width="14%">Date of Losses: </td>
<td width="14%">
<input type="text" maxlength = 2 size=2 name="txtLossdd" value="<%=strLossdd%>" checkDay(this)">-
<input type="text" maxlength = 2 size=2 name="txtLossmm" value="<%=strLossmm%>" checkMonth(this)">-
<input type="text" maxlength = 4 size=4 name="txtLossyyyy" value="<%=strLossyyyy%>" checkLossDate()">
</TD>

The JS function

function checkLossDate()
{
alert("Test");
var lossDD=document.frmSicsClmHdrSetup.txtLossddFrom.value;


The first three lines of the function.The first alert not being called. I have used the same logic in one of my other JSP's.There it worked fine. I know i am missing some silly things.

View 1 Replies View Related

Onblur For <div> Is Not Working?

Feb 21, 2009

The onblur event for <div> or <table> is not working while it is working for <input checkbox, text> fields

<div id="abc"
onblur="onblur();">
<table style="border-top: none;color: black; border="0" cellpadding="0" cellspacing="0" onblur="onblur();">

[Code].....

View 6 Replies View Related

BODY OnBlur Event?

Jul 23, 2005

I'm having some trouble with the "onBlur" event in the BODY tag.
Ideally, what I want to happen is that when someone leaves window A,
window A executes a command. I had put

<body onBlur="savePage();">

I have a couple of problems. On IE 6 (win2000), whenever I put the
cursor focus on a textfield within window A, the "savePage" function
is invoked. And on Mozilla Filefox 0.9.1, the event never launches
even when I leave the window.

Does anyone know how I can solve these respective problems?

View 2 Replies View Related

What Is The Replacement For OnBlur In Mozilla

Jan 21, 2006

What is the replacement for onBlur in Mozilla

<body STYLE='background-color:buttonface;' leftmargin=0 rightmargin=0
topmargin=0 bottommargin=0 onBlur="window.focus()">

View 1 Replies View Related

How To Submit A Form Onblur?

Jul 20, 2005

I'm trying to make sure that a form gets submitted when the person leaves this field.

<input type="text" name="prospectNameOrId" size="50" value=""
onblur="setUserAction('Add Prospect'); document.forms[0].submit();">

In IE6, I get 'Object doesn't support this property or method'. I'm using document.forms[0] elsewhere, and I have found examples on the web using this syntax, so I'm not sure what the problem is. Can I not do this in onblur?

Is there a better way to do it? (I'm a Java programmer, not too experienced in JavaScript.)

View 3 Replies View Related

Focus OnBlur In Firefox?

Feb 26, 2009

I have a problem where there is an onBlur check for a valid entry. The javascript checks the entry and if it is incorrect it does an alert and then puts the focus back onto the incorrect field, so valid data has to be entered.

This is a generic function so it uses 'this' - onBlur="chkMonthDob(this);"

The function then checks it and puts the focus back on 'this' if it is wrong. This all works fine in IE but in Firefox it does not put the focus back.

Using the Firefox getaround :- setTimeout("document.orgsp.d1_org_dob_mth.focus()", 1); works, however, when it is called with 'this' as a parameter you don't know what the field is to be focussed on, so I had hoped that putting :-

var focusField = myField.id;
setTimeout("document.getElementById(focusField).focus()", 1);

would work - but Firefox say focusField is undefined.

View 1 Replies View Related

How To Know Tab Key Is Pressed OnBlur Or Onkeypress

Jun 8, 2009

Since key code for Tab key is not working, find whether tab key is pressed onblur or onkeypress

View 5 Replies View Related

OnBlur Function Does Not Work In IE6 / IE7

Dec 9, 2010

I have a problem with one simple script, which works in every browser, just not in IE6 and IE7. You can see the script at [uRL] - when you click on the iframe, you should see "clicked at the bottom". But it doesn't work in IE6 and IE7.

View 2 Replies View Related

OnBlur() Function Not Working?

Dec 29, 2009

why my onblur() function is not working in javascript.Code is pretty simple. Its a text box with an onblur() function showing an alert. I have used it long back.. But i could not figure out why its not working now.. I dont know what the silly mistake i have made.

View 4 Replies View Related

Use More Than One Onblur For Calling Different Functions?

Mar 2, 2010

In my project I'm using onblur event in four text boxes and using that onblur event i wanna call different javascript functions i.e', like first text box onblur="test()" and in second text box onblur="test1()" etc. But only one onblur onblur is calling the function and other onblurs are not working. So pls tell me how can i put more the one onblur event and javascript functions in a single page.

View 7 Replies View Related

Can I Use OnBlur In Body For IE Browsers?

Dec 1, 2003

I am trying to use a simple JavaScript command to close the window when it is no longer in focus: BODY onBlur=window.close();

This works in IE 5.1 for Mac and in Mozilla/Netscape, but in the Windows IE browsers I have tried, clicking anywhere closes the window, even clicking on the Flash animation in the window itself. Very bad. Code:

View 2 Replies View Related







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