473,508 Members | 2,263 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Pass an event to a dynamicly created function in IE

392 Recognized Expert Contributor
Hi,

I am trying to find the correct syntax to pass an event object to a dynamically created function. When I do something like

object.onclick = new Funtion(" myFunction(event, someVar); ");

I get an error saying event is not defined. I found I can do this in FireFox.

object.onclick = funtion(event) { myFunction(event, someVar); };
object.onclick = new Funtion("event, someVar ", "myFunction(event, someVar);" };


But in IE the event object is passed as undefined. Does any one know how to do this in IE?
Mar 5 '07 #1
2 1428
sumittyagi
202 Recognized Expert New Member
IE don't pass the event object to the function to which it is attached.
It stores the most resent event in the property window.event.

so the code you have to add for this is simply
function (ev){
/*if ev would be undefined then it would be read from window.event*/
ev = ev || wondow.event;
..
..
}

it will solve your problem.

If you know about uploaded image-size validation, then please help me in this context, refer to my post uploaded image-size validation.
Mar 5 '07 #2
pronerd
392 Recognized Expert Contributor
IE don't pass the event object to the function to which it is attached.
It stores the most resent event in the property window.event.

ev = ev || wondow.event;

Thanks I remembered that last night, but was too tired to post the solustion.

Any idea why this passes the Event in IE
<span id="someTestTag" onclick="myFunction(event);" >


But this does not?

<span id="someTestTag" onclick="myFunction(event);" >
document.getElementById( 'someTestTag' ).onclick = function(event) { myFunction(event); };



If you know about uploaded image-size validation, then please help me in this context, refer to my post uploaded image-size validation.
Will do. I have worked with this, but only on the Server side there are no real JS options
Mar 5 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
3304
by: Zlatko Matić | last post by:
Hi everybody! Recently I was struggling with client/server issues in MS Access/PostgreSQL combination. Although Access is intuitive and easy to use desktop database solution, many problems...
0
975
by: Emrah Gozcu | last post by:
I have a custom control tabstrib and it loads another custom control when clicked a tab. Tabstrib event fires well but the other custom control which is dynamicly loaded after clicking a tab,...
0
1023
by: Emrah Gozcu | last post by:
I have a custom control tabstrib and it loads another custom control when clicked a tab. Tabstrib event fires well but the other custom control which is dynamicly loaded after clicking a tab,...
1
1789
by: Henke | last post by:
Hi I have a aspx-page with a panel-control. On this panel control I add user controls dynamicly with LoadControl and panel.Controls.Add(myControl). On some of the dynamicly added user controls I...
1
946
by: jose | last post by:
Hello!! I am trying to declare an event in the service Web to soon be able to use it in the clients but there is no way. In order to declare a function in the service Web it is very simple: <...
7
1647
by: Raymond Lewallen | last post by:
Which would be the proper way or the reason for using any of the following or combinations of the following? These are the 3 ways I've figured I can do what I want to do, I just don't know which...
10
2487
by: Sean Dockery | last post by:
I have the following HTML file that I've been using for testing... <html> <head> <script type="text/javascript"> <!-- function handleWindowLoad() { var items = ; for (var i = 0; i < 11; i++)...
6
2249
by: Class | last post by:
Hi all, I create a gridview dynamicly because I don't know the columns in advance. I use the Templatefield to create a linkbutton. Everything fine..I have the postbackurl and it works. But now...
24
55038
by: =?Utf-8?B?U3dhcHB5?= | last post by:
Can anyone suggest me to pass more parameters other than two parameter for events like the following? Event: Onbutton_click(object sender, EventArgs e)" Event handler: button.Click += new...
0
7231
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7132
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7401
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7063
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7504
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5640
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4720
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3211
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1568
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.