admin管理员组文章数量:1415139
I am getting a Not Implemented error when trying to screen the screen-width into a hidden field on page load. Looking at other similar issues, they've all suggested putting everything in variables and making sure I wasn't using reserved words. I have and I am not (that I know of).
function GetScreenWidth() {
var sWidth = screen.width;
var hfSw = document.getElementById("<% =hfScreenWidth.ClientID %>");
hfSw.value = sWidth;
}
window.onload = GetScreenWidth();
Originally, I was using
function GetScreenWidth() {
document.getElementById("<% =hfScreenWidth.ClientID %>").value = screen.width;
}
Ultimately, I'm trying to get the screen-width back into the code-behind. If there are better ways to do that, I'd love to hear them.
EDIT: the hidden field is defined above the tag.
I am getting a Not Implemented error when trying to screen the screen-width into a hidden field on page load. Looking at other similar issues, they've all suggested putting everything in variables and making sure I wasn't using reserved words. I have and I am not (that I know of).
function GetScreenWidth() {
var sWidth = screen.width;
var hfSw = document.getElementById("<% =hfScreenWidth.ClientID %>");
hfSw.value = sWidth;
}
window.onload = GetScreenWidth();
Originally, I was using
function GetScreenWidth() {
document.getElementById("<% =hfScreenWidth.ClientID %>").value = screen.width;
}
Ultimately, I'm trying to get the screen-width back into the code-behind. If there are better ways to do that, I'd love to hear them.
EDIT: the hidden field is defined above the tag.
Share Improve this question asked May 30, 2013 at 21:30 TravisTravis 1,1051 gold badge17 silver badges37 bronze badges 1- What browser are you using? What line is throwing the error? Is it a server error or a JavaScript error? – Colin DeClue Commented May 30, 2013 at 21:34
1 Answer
Reset to default 3I've seen this error message under IE when setting unexpected values to event handlers. Basically, you're setting onload
to a value of undefined
(as that's what your function returns), which could cause all sorts of weird behavior. You probably want to bind a reference to GetScreenWidth
to the event handler, like so:
window.onload = GetScreenWidth;
Or perhaps:
window.onload = function () {
var sWidth = screen.width;
var hfSw = document.getElementById("<% =hfScreenWidth.ClientID %>");
hfSw.value = sWidth;
};
Or, if you happen to be using jQuery:
$(function () {
var sWidth = screen.width;
var hfSw = document.getElementById("<% =hfScreenWidth.ClientID %>");
hfSw.value = sWidth;
});
本文标签: Javascript Not Implemented errorStack Overflow
版权声明:本文标题:Javascript Not Implemented error - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745226966a2648651.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论