yui

Execute function before refresh

一世执手 提交于 2019-11-26 17:32:59
问题 On my HTML page, when the user clicks / presses F5 button the page refreshes, but before it refreshes I want to execute a function or a simple alert. User can click on refresh button, press F5 or Ctrl + R . Using core JavaScript, jQuery or YUI. 回答1: window.onbeforeunload = function(event) { return confirm("Confirm refresh"); }; 回答2: $(window).bind('beforeunload', function(){ return '>>>>>Before You Go<<<<<<<< \n Your custom message go here'; }); Source: http://www.mkyong.com/jquery/how-to

Need to find height of hidden div on page (set to display:none)

六月ゝ 毕业季﹏ 提交于 2019-11-26 09:46:23
问题 I need to measure the offsetHeight of a div that is inside of a hidden element. <div id=\"parent\" style=\"display: none;\"> <div id=\"child\">Lorem Ipsum dolor sit amet.</div> </div> The parent div must be set to \" display:none \". I have no control over that. I realize that the offsetHeight of the child div is going to be 0. I need to find a workaround. Something I\'ve toyed with is when the page loads, I copy the childnodes of parent, inject in a div on the page that is set to \"

Set Value of Input Using Javascript Function

谁说胖子不能爱 提交于 2019-11-26 03:34:02
问题 I\'m currently using a YUI gadget. I also do have a Javascript function to validate the output that comes from the div that YUI draws for me: Event.on(\"addGadgetUrl\", \"click\", function(){ var url = Dom.get(\"gadget_url\").value; /* line x ------>*/ if (url == \"\") { error.innerHTML = \"<p> error\" /></p>\"; } else { /* line y ---> */ /* I need to add some code in here to set the value of \"gadget_url\" by \"\" */ } }, null, true); Here is my div : <div> <p>URL</p> <input type=\"text\"