Current location: Hot Scripts Forums » General Web Coding » HTML/XHTML/XML » Problems with event binding


Problems with event binding

Reply
  #1 (permalink)  
Old 02-25-09, 03:35 AM
eddiefisher41 eddiefisher41 is offline
New Member
 
Join Date: Feb 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Problems with event binding

Hi Guys.

Having a few problems binding an event to the loading event of a HTML page.

<body onLoad='http:........../HTML_Generate.py'>

I need the python script to be run at load time. The python script prints another set of HTML lines that need to be run at load up.

The script runs fine, with all functionality and no problems etc. Unfortunately I get a bind error from the HTML side.

Cheers.
Ed
Reply With Quote
  #2 (permalink)  
Old 02-26-09, 08:15 PM
dirtydoug dirtydoug is offline
Newbie Coder
 
Join Date: Feb 2009
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
i have same inquiry, instead of posting another topic i think i should just wait for this to be answered.

thanks!
Reply With Quote
  #3 (permalink)  
Old 03-07-09, 02:25 AM
dgreenhouse's Avatar
dgreenhouse dgreenhouse is offline
Aspiring Coder
 
Join Date: Mar 2009
Location: San Francisco
Posts: 457
Thanks: 0
Thanked 3 Times in 3 Posts
If you're still there...

You'll want to create a JavaScript function and call out to your Python script from there.

Maybe you want the results of the Python script placed into a <div> or maybe loaded directly into an iFrame.

Even though the events model is quite flexible, you're going about this the wrong way.

I mean, does this make any sense: <body onLoad="http://www.google.com">?

Maybe I'm missing something here... But I don't think so...
Reply With Quote
  #4 (permalink)  
Old 03-09-09, 11:47 AM
eddiefisher41 eddiefisher41 is offline
New Member
 
Join Date: Feb 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
The Python script runs fine if I use a click button event. I just want the same functionality with the onLoad event.
Cheers.
Ed
Reply With Quote
  #5 (permalink)  
Old 03-10-09, 12:07 AM
dgreenhouse's Avatar
dgreenhouse dgreenhouse is offline
Aspiring Coder
 
Join Date: Mar 2009
Location: San Francisco
Posts: 457
Thanks: 0
Thanked 3 Times in 3 Posts
Well I'm not sure what the Python script does, but you'll still need to call it from a function if you're going to use the onload event.

I'm a little unsure what you are trying to accomplish by trying to initiate the Python script via the body's onload event.

Are you trying to load the script into the browser as if you typed the script's path directly into the address bar?

If so, why don't you just go there from a link?

If it's an issue of starting with a certain URL and then going out to the Python script, then you need to; as stated, load the URL with JavaScript or do a meta-refresh out to the page.

But as I said, I'm unclear on why you're trying to do this from the body's onload event.

Last edited by dgreenhouse; 03-10-09 at 12:10 AM.
Reply With Quote
  #6 (permalink)  
Old 03-10-09, 12:36 AM
dgreenhouse's Avatar
dgreenhouse dgreenhouse is offline
Aspiring Coder
 
Join Date: Mar 2009
Location: San Francisco
Posts: 457
Thanks: 0
Thanked 3 Times in 3 Posts
If you truly want to load the Python script from the onload() event, you can try this:

Code:
<html>
<body onload="javascript:document.location='http://google.com';">

</body>
</html>
... or ...

Code:
<html>
<script>
function loadURL() {
  document.location = "http://google.com";
}
</script>
<body onload="loadURL();">

</body>
</html>
But this assumes that JavaScript is enabled in the browser on the user end.

You don't even need to; as the first example shows, have a function defined.

I assume you know that; just like the onclick() event of a button, the body's onload() event, is an event - not a method per se.

Events can call methods, but they are asynchronous by design.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Rip Open- Event on open source development. s.rao The Lounge 1 01-23-09 01:55 PM
Rip Open- Event on open source development s.rao The Lounge 0 12-22-08 02:35 AM
Differentiate between mouseup event and click event daivagna JavaScript 3 11-06-07 07:44 AM


All times are GMT -5. The time now is 09:03 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.