简体   繁体   中英

How to call a JavaScript function on page load event?

I am calling a JavaScript function in a page to load an event as follows:

Page.ClientScript.RegisterStartupScript(this.GetType(), "Script12", "Disable();", true);

The Disable() function is:

function Disable() {
   var ed = tinyMCE.activeEditor;
   ed.getBody().setAttribute('contenteditable', false);
}

But, when my page loads, it is not working as intended. Are there any obvious errors in my code? Is my Disable() function implemented correctly?

You can use jQuery ready function. Just include the reference of jQuery library (http://docs.jquery.com/Downloading_jQuery) in your page & call like this.

<script src="../jquery-1.7.1.min.js"></script>
<script>
$(function() {
 Disable();
});
</script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM