Javascript/Firefox: window.innerHeight minimum seems to be 100px
I have a simple javascript program that's acting a little funny. When I try to specify window.innerHeight to be开发者_StackOverflow中文版 under 100px, my specification is overridden and a value of 100px is used instead.
The code below does not create a 30px high inner-window as might be expected. Instead the window is 100px. The alert similarly reads "100".
Any idea on how to fix this?
function loadVideo() {
var args = fetchArguments();
iframe = document.createElement("iframe");
iframe.title = "YouTube video player";
iframe.class = "youtube-player";
iframe.type = "text/html";
iframe.width = args["width"];
iframe.height = args["height"];
iframe.src = "http://www.youtube.com/embed/" + args["vid"];
iframe.frameborder="0";
iframe.allowFullScreen;
document.getElementsByTagName("body")[0].appendChild(iframe); // we append the iframe to the document's body
window.innerHeight= 30; //args["height"];
window.innerWidth=args["width"];
alert(window.innerHeight);
self.focus();
}
Firefox won't let you create a window of less than 100 pixels in height or width. This is a security restriction.
You should be setting window.innerHeight/innerWidth with a number not a string. Toss a parseInt around your "args['height']" variable.
Updated
SoundCloud provides an direct embed for their Flash player, here's a sample of it:
<object height="81" width="100%">
<param name="movie" value="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F8407161"></param>
<param name="allowscriptaccess" value="always"></param>
<embed allowscriptaccess="always" height="81" src="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F8407161" type="application/x-shockwave-flash" width="100%"></embed>
</object>
Note that you can set the height and width values directly on the <object> tag. So just write the embed tag out into the body of the popup, setting the popup height to 81px and width to whatever you want (at least 300px, so it looks okay).
Updated Again
The real question here is how you open a popup window in a browser with specific content (read html content) size. You can set the size of a popup in window.open but that will be the total size of the popup window including the browser chrome.
精彩评论