<p>I have a JavaScript method that I need to run on one of my pages, in particular, the <code>onresize</code> event.  </p>

<p>However, I don't see how I can set that event from my content page.  I wish I could just put it on my master page, but I don't have the need for the method to be called on all pages that use that master page.</p>

<p>Any help would be appreciated.</p>

[{'answer_id': 33440, 'author': 'Jason Bunting', 'author_id': 1790, 'author_profile': 'https://Stackoverflow.com/users/1790', 'pm_score': 3, 'selected': True, 'text': '<p>Place the following in your content page:</p>\n\n<pre><code>&lt;script type="text/javascript"&gt;\n\n// here is a cross-browser compatible way of connecting \n// handlers to events, in case you don\'t have one\nfunction attachEventHandler(element, eventToHandle, eventHandler) {\n    if(element.attachEvent) {\n       element.attachEvent(eventToHandle, eventHandler);\n    } else if(element.addEventListener) {\n       element.addEventListener(eventToHandle.replace("on", ""), eventHandler, false);\n    } else {\n    element[eventToHandle] = eventHandler;\n  }\n}\n\nattachEventHandler(window, "onresize", function() {\n    // the code you want to run when the browser is resized\n});\n\n&lt;/script&gt;\n</code></pre>\n\n<hr>\n\n<p>That code should give you the basic idea of what you need to do. Hopefully you are using a library that already has code to help you write up event handlers and such.</p>\n'}, {'answer_id': 33603, 'author': 'Adhip Gupta', 'author_id': 384, 'author_profile': 'https://Stackoverflow.com/users/384', 'pm_score': 0, 'selected': False, 'text': '<p>How about use code like the following in your Content Page (C#)?</p>\n\n<pre><code>Page.ClientScript.RegisterStartupScript(this.GetType(), "resizeMyPage", "window.onresize=function(){ resizeMyPage();}", true);\n</code></pre>\n\n<p>Thus, you could have a <code>resizeMyPage</code> function defined somewhere in the Javascript and it would be run whenever the browser is resized!</p>\n'}, {'answer_id': 887139, 'author': 'Gordon Thompson', 'author_id': 21299, 'author_profile': 'https://Stackoverflow.com/users/21299', 'pm_score': 0, 'selected': False, 'text': '<p>I had the same problem and have come across this post :</p>\n\n<p><a href="http://blog.stchur.com/2006/09/06/the-ie-resize-bug-revisited/" rel="nofollow noreferrer">IE Resize Bug Revisited</a></p>\n\n<p>The above code works but IE has a problem where the onresize is triggered when the body tag changes shape. This blog gives an alternate method which works well</p>\n'}]
['https://Stackoverflow.com/questions/33301', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1226/']