Supporting each other

Community forums

Welcome, Guest
Username: Password: Remember me
General questions and topics about Xerte Toolkits that don’t fit anywhere else.
  • Page:
  • 1
  • 2

TOPIC:

"onload" event 7 years 9 months ago #4200

  • Robert Fant
  • Robert Fant's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 10
  • Thank you received: 0
The "onload" event is often placed in the <body> tag, or various other tags.
I'm wanting to run a script when a page is loaded, but unfortunately I can't figure out where to place it in my various pages.

Your assistance is greatly appreciated.

Thanks,
Robert

Please Log in or Create an account to join the conversation.

"onload" event 7 years 9 months ago #4202

  • Fay
  • Fay's Avatar
  • Offline
  • Elite Member
  • Elite Member
  • Posts: 229
  • Thank you received: 92
Every page has a 'script' optional property that you can add. Any javascript added to this field will be executed after the page has been loaded for the 1st time.

Please Log in or Create an account to join the conversation.

"onload" event 7 years 9 months ago #4204

  • Robert Fant
  • Robert Fant's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 10
  • Thank you received: 0
Hi Fay,

Yes, I am aware of the JavaScript property.
However, the "onload" command/attribute (whatever) does not stand-alone, it is generally placed inside a tag such as,

<body onload="MyScript()" >

so when the body (document) is loaded, the MyScript function is called.

I need an alternative method of getting my script to run as soon as I open that particular page.

Thanks,

Please Log in or Create an account to join the conversation.

"onload" event 7 years 9 months ago #4205

  • ronm
  • ronm's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 847
  • Thank you received: 260
In the script text box just add MyScript();
Xerte developer & trainer
e-learning & m-learning consultant
mitchellmedia.co.uk | xerteacademy.com | learningapps.co.uk
Note: Support here is voluntary and meant for users to support each other.
Need direct commercial support with Xerte? mitchellmedia.co.uk/contact/
The following user(s) said Thank You: Robert Fant

Please Log in or Create an account to join the conversation.

"onload" event 7 years 9 months ago #4206

  • Fay
  • Fay's Avatar
  • Offline
  • Elite Member
  • Elite Member
  • Posts: 229
  • Thank you received: 92
Do you need it to run before anything else on the page is set up? If so then I don't think there is a way of doing this at the moment (although I would like to look at better scripting support at some point).

Can't you just put your MyScript function in the optional property field and call it from there?

Please Log in or Create an account to join the conversation.

"onload" event 7 years 9 months ago #4207

  • tom
  • tom's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 1274
  • Thank you received: 320
I am not sure which 'pages' you're referring to, but I suspect pages in a Xerte Online Toolkits LO.

Please do realsie that there is only one body element, and that all the content is loaded dynamically, so onload in body wouldn't wordk in this case.

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
  • 2
Moderators: ingdon
Time to create page: 0.052 seconds
Copyright © 2024 The Xerte Project.
Xerte logo Apereo logo OSI Logo

Search