JavaScript - Javascript Page Height And Width
Hi guys, was just wondering if there was a way to control the page height and width using js/jquery?
I have a page that is: width: 980px height: 2500px I would like the page height to be set to around 900px with the viewable scrollbar and all other content not viewable underneath. Any help is appreciated Cheers, paffley Similar TutorialsHi, well earlier i asked for a script which can load game which showing some banner until the game is loading and the load progress that it shows, it shouldn't be fake, many people said you need flash for it, but atlast i found a script that can do that for me. BUT there is a issue when i started using the script in the script the width and height can be in px like width 500 but it can't be made to width 100% when i make it 100% the script stops working. I can't use px or any other thing except 100% as i want the flash to increase its width and height with the change in screen resolution. Here is the script, you can make a demo html file out of it for testing purposes, if you don't want to make one i am ready to provide a demo page too, please leave a comment for it. Thank you ^_^ Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Pre-roll Example page</title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script> <script type="text/javascript" src="http://files.cryoffalcon.com/woro/preroll.dev.js"></script> <style> .gamecontent {width:923px;padding:0px;margin:0px auto 0px auto;background-color:#FFF;} .gamecontent .gamewrapper {margin:0px auto 0px auto;} .gamecontent .game {float:left;margin:0px auto 0px auto;padding:0px;overflow:hidden;width:1px;height:1px} .gamecontent .ad {display:none;width:300px;height:300px;margin:0px auto 0px auto;padding:50px auto 0px auto;text-align:center;font-size:10px} .gamecontent .ad #progress {width:200px;height:10px;margin:10px auto 0px auto;padding:0px;border:solid 1px #E7B9D1;text-align:left;} .gamecontent .ad #pbar {width:0px;height:10px;background-color:#CCC;} .gamecontent .ad #pskip {text-align:center;} .medrectangle {width:300px;height:250px;border:none} </style> </head> <body> <div class="gamecontent"> <div class="gamewrapper" style="height:640px;width:640px;"> <div class="game" id="gameframe"></div> <div id="adframe" class="ad"> <div>Advertisement</div> <div id="plad"></div> <div id="progress"></div> </div> <noscript> <div> <!--Game embed code should be placed here here--> </div> </noscript> </div> </div> <script type="text/javascript" language="javascript"> var af = 'adframe'; var gf = 'gameframe'; var gid = 'gameswf'; var adinvoke = '<iframe class="medrectangle" src="<!--to show my logo or ad-->" scrolling="no"></iframe>'; function skipad() { $('#plad').html('<div></div>'); $('#'+af).hide(); $('#'+gf).css('width','640px'); $('#'+gf).css('height','640px'); } $('#gameframe').preloadad( { // calls the init method swf : 'http://games.balloontowerdefense.net/b/balloon_tower_defense_4_expansion.swf', width : 640, height : 640, gameid : gid, gameframe : gf, adframe : af, adcode : adinvoke, pltime : 10000, gametype : 'swf', base :'http://games.balloontowerdefense.net/b/', skiptxt : 'Click here to show the game', showad :'1' }); </script> </body> </html> in the above code the 640 width and height is the issue, as it doesn't work with 100% values, i was wondering how to make it work with 100% width and height. I don't know what did i miss or where did i go wrong? Hello guys ! I'm fairly new to JavaScript, so this is maybe an obvious mistake, but here is the code that doesn't work, it goes inside the body of my document : Code: <script type="text/javascript"> aImg = new Image(); aImg.src = "myimage.jpg"; aHeight = aImg.height; aWidth = aImg.width; document.write(aHeight + "," + aWidth); document.write("<img src=" + aImg.src + ">"); </script> While the image is displayed, the value written for the height and width is "0". This code worked fine when I compiled it in the "Tryit Editor" of w3schools.com (I told you I was new to JS :P), but it fails when I insert it in a page and then view the page with Google Chrome or IE7. Of course this is not all fo the code, I intend to display the image differently depending of its size... but I need to get that part right before moving on Any help would be greatly apreciated, thanks ! Hi My html document contain many images which has the attribute src of img tag as the flowing : PHP Code: http://images.mysite.com/a/p/ap.eba553af4b719.ec03.jpg?x=210&y=83&q=85&sig=Tua1ukyUEVKTPSsz7xGPsg-- All those images has the common source folder http://images.mysite.com/a/p This is an example : PHP Code: <img src = "http://images.mysite.com/a/p/ap.eba553af4b719.ec03.jpg?x=210&y=83&q=85&sig=Tua1ukyUEVKTPSsz7xGPsg--" width = "105" height = "73" > I tried during many days to find the solution using RegExp but I didn't arrives. What I want to do is I - change for all image from the seem folder the src attribute to match the exact url of the image without special characters, for this example : PHP Code: http://images.mysite.com/a/p/ap.eba553af4b719.ec03.jpg?x=210&y=83&q=85&sig=Tua1ukyUEVKTPSsz7xGPsg-- Became : PHP Code: http://images.mysite.com/a/p/ap.eba553af4b719.ec03.jpg II - Control the width and height of the image by changing its height and width attributes resp. from two javascript variables : PHP Code: var v_width = 320 // Just for example var v_height = 250 // Just for example This is an example of try didn't work for me, for the first issue : PHP Code: var element = document.getElementsByTagName("img"); for(var i=0;i<element.length;) { var myString = new String(); var myRegExp = new RegExp("http:\/\/d\.images\.mysite\.com\/a\/p[^\?]*(jpg|png|gif)","i"); var myRegExp0 = new RegExp("\?.*","i"); myString = element[i].getAttribute("src"); if(myRegExp.test(myString)) { var newString = myString.replace(myRegExp0,""); element[i].setAttribute("src",newString); } } Help me please Think you Hi I have embeded a video like this: Code: <div class="videoDiv" id="showDis"> <object classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" id="MediaPlayer1"> <param name="url" value="http://mysite/myvideo.wmv""> <param name="src" value="http://mysite/myvideo.wmv""> <param name="showcontrols" value="true"> <param name="autostart" value="true"> <!--[if !IE]>--> <object type="video/x-ms-wmv" data="http://mysite/myvideo.wmv""> <param name="src" value="http://mysite/myvideo.wmv""> <param name="autostart" value="true"> <param name="controller" value="true"> </object> <!--<![endif]--> </object> </div> I would like to retrieve the video's width and height (resolution), for example: 640x480 how can I do that via JavaScript? this is what I tried: Code: var objPlayer = document.MediaPlayer1; alert(objPlayer.offsetWidth); alert(objPlayer.width); alert(document.getElementById('showDis').style.width); alert(document.getElementById('showDis').style.offsetWidth); nothing gives me the real value. even looked he http://msdn.microsoft.com/en-us/libr...(v=VS.85).aspx but couldn't find anything relevant I have embeded a video like this: Code: <div class="videoDiv" id="showDis"> <object classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" id="MediaPlayer1"> <param name="url" value="http://mysite/myvideo.wmv""> <param name="src" value="http://mysite/myvideo.wmv""> <param name="showcontrols" value="true"> <param name="autostart" value="true"> <!--[if !IE]>--> <object type="video/x-ms-wmv" data="http://mysite/myvideo.wmv""> <param name="src" value="http://mysite/myvideo.wmv""> <param name="autostart" value="true"> <param name="controller" value="true"> </object> <!--<![endif]--> </object> </div> I would like to retrieve the video's width and height (resolution), for example: 640x480 how can I do that via JavaScript? this is what I tried: Code: var objPlayer = document.MediaPlayer1; alert(objPlayer.offsetWidth); alert(objPlayer.width); alert(document.getElementById('showDis').style.width); alert(document.getElementById('showDis').style.offsetWidth); nothing gives me the real value. even looked he http://msdn.microsoft.com/en-us/libr...(v=VS.85).aspx but couldn't find anything relevant Hey guys i am test my page in IE8 and i have a small problem the following script works in other browsers but not IE8 Code: function preload(arrayOfImages) { $(arrayOfImages).each(function () { $('<img />').attr('width', '100px').attr('height', '100px').attr('src',this).appendTo('#img').attr('class', 'img'); setTimeout(this, 2000); }); } when i run this with lets say 100 images and all the image sizes are all diffrent and above 150px*150px when this runs it will preload the images fine BUT it loads the images with their defualt width & height and not 100px*100px any idea why this is? I am trying to customize this scrollbar so that it will fit all screen resolutions and I was wondering how I could do this by somehow customizing the JavaScript files created by Nathan Faubion or if I could do this using other JavaScript variables (var widthPercentage) to change the pixels to percentages? Please let me know what you think. Thank you very much! One of the pages on the website I'm using the JavaScript on: http://www.clintshipley.com/about.html Code: JavaScript file jsScroller.js: //Created by Nathan Faubion http://www.n-son.com/scripts/jsScrolling/ function jsScroller (o, w, h) { var self = this; var list = o.getElementsByTagName("div"); for (var i = 0; i < list.length; i++) { if (list[i].className.indexOf("scroller-content") > -1) { o = list[i]; } } //Private methods this._setPos = function (x, y) { if (x < this.viewableWidth - this.totalWidth) x = this.viewableWidth - this.totalWidth; if (x > 0) x = 0; if (y < this.viewableHeight - this.totalHeight) y = this.viewableHeight - this.totalHeight; if (y > 0) y = 0; this._x = x; this._y = y; with (o.style) { left = this._x +"px"; top = this._y +"px"; } }; //Public Methods this.reset = function () { this.content = o; this.totalHeight = o.offsetHeight; this.totalWidth = o.offsetWidth; this._x = 0; this._y = 0; with (o.style) { left = "0px"; top = "0px"; } }; this.scrollBy = function (x, y) { this._setPos(this._x + x, this._y + y); }; this.scrollTo = function (x, y) { this._setPos(-x, -y); }; this.stopScroll = function () { if (this.scrollTimer) window.clearInterval(this.scrollTimer); }; this.startScroll = function (x, y) { this.stopScroll(); this.scrollTimer = window.setInterval( function(){ self.scrollBy(x, y); }, 40 ); }; this.swapContent = function (c, w, h) { o = c; var list = o.getElementsByTagName("div"); for (var i = 0; i < list.length; i++) { if (list[i].className.indexOf("scroller-content") > -1) { o = list[i]; } } if (w) this.viewableWidth = w; if (h) this.viewableHeight = h; this.reset(); }; //variables this.content = o; this.viewableWidth = w; this.viewableHeight = h; this.totalWidth = o.offsetWidth; this.totalHeight = o.offsetHeight; this.scrollTimer = null; this.reset(); }; JavaScript on HTML page: <script type="text/javascript" src="Scripts/jsScroller.js"></script> <script type="text/javascript" src="Scripts/jsScrollbar.js"></script> <script type="text/javascript"> var scroller = null; var scrollbar = null; window.onload = function () { scroller = new jsScroller(document.getElementById("scroller"), 550, 275); scrollbar = new jsScrollbar (document.getElementById("scrollbar-content"), scroller, false); } </script> Hi, I need to re-size a div to be 100% of the browser but taking into account the height of an existing header div. Currently it works but it doesn't factor the height of the above header div, and therefore scrolls off the page (the height of the header div) I need to manipulate ( subtract the height value of the header) in the javascript somehow. Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <script type="text/javascript"> function SetHeightOfDiv(){ var theDiv = document.getElementById('content'); theDiv.style.height = BrowserHeight()+"px"; } function BrowserHeight() { var theHeight; if (window.innerHeight) { theHeight = window.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) { theHeight = document.documentElement.clientHeight; } else if (document.body) { theHeight = document.body.clientHeight; } return theHeight; } </script> </head> <body style="height:100%; background-color:blue; margin:0; padding:0; color:#ffffff; font-size:15px; text-align:center; font-family:monospace,arial" onload="SetHeightOfDiv()"> <div id="wrapper" style="height:100%; width:900px; background-color:yellow; margin-left:auto; margin-right:auto; overflow:hidden"> <div id="header" style="margin-top:0px; height:130px; width:890px; margin-left:5px; background-color:red; position:fixed"> <p>The FIXED HEADER</p> </div> <div id="content" style="margin-top:132px; background-color:grey; width:890px; margin-left:5px"> <p>THE BODY - that extends below the browser window (possibly the height of the header)</p></br> <p>So how do we manipulate the Javascript to 'Subtract' the height of the HEADER?</p></br> <p style="text-align:left; padding-left:10px"> function SetHeightOfDiv(){ <br> var theDiv = document.getElementById('content');<br> theDiv.style.height = BrowserHeight()+"px";<br> }<br> </br> function BrowserHeight() {<br> var theHeight;<br> if (window.innerHeight) {<br> theHeight = window.innerHeight;<br> }<br> else if (document.documentElement && document.documentElement.clientHeight) {<br> theHeight = document.documentElement.clientHeight;<br> }<br> else if (document.body) {<br> theHeight = document.body.clientHeight;<br> }<br> return theHeight;<br> }</p> </div> </div> <!--end of wrapper--> </body> </html> Thanks Hey guys, so i have a comment section. And what i want to do is if the height of the comment box is larger then lets say 100px. I want to set the height of the comment box to 50px and then display a "read more" button. And this read more button would toggle and allow the height to be "auto" and not set to 50px. so my html would look like this Code: <div class="comment-section"> <div class="comment"><p>This is where text would go. </p></div> <div class="read-more">Read More</div> </div> I have the class "read-more" set to "display:none" How would i do this? This is what i have / was trying and have been unsuccessful Code: <script type="text/javascript"> $(function(if ($".comment".style.height > 100px;){ { $".comment".style.height = 50px; $".read-more".style.display = block; } }); </script> I am struggling to find a solution that enables me to have a div that is a certain percentage height of the window and then when the user is using a different resolution, it remains at that percentage of the screen height - not going off of the bottom as I have a fixed percentage no scroll full background image. I have sorted it for width but can't get it to work for height. any ideas? lol Bee x I have a CSS file associated with this that sets the width at "200px." However, I am getting a 40px wide dropdown. Can anybody catch an error in here? Using console.log, I found that el, as soon as it is defined, is = div.dropdown. As soon as .width comes into the picture, it returns as six consecutive 101px and a ton of 40px after that... and continues returning those values till the end. I appreciate any input!! Code: var Dropdown = function(el) { this.el = el; this.handle = el.find("div.dropdown-text"); this.options = el.find("div.dropdown-options"); this.optionsWrap = this.options.parent(); this.action = el.attr("action"); this.type = el.attr("type"); this.target = el.attr("target"); this.Init(); } Dropdown.prototype.Init = function() { var self = this; var extraPadding = 40; this.isShown = false; console.log(this); this.width = this.options.outerWidth() + extraPadding; this.height = this.options.outerHeight(); if (this.height > 300) { this.height = 300; this.options .height(300) .width(this.width + 12) .addClass("scroll-pane") .jScrollPane({ showArrows: true, scrollbarWidth: 9 }) this.width += 12; } else { this.options.width(this.options.width() + extraPadding); } var newWidth = (this.width < 220) ? this.width : 220; this.el.width(newWidth); this._AddShadow(); this.optionsWrap.css({ display: "none", visibility: "visible", width: this.width + 5, height: this.height + 5 }); this._SetEvents(); }; Dropdown.prototype.Toggle = function(force) { if (this.isShown && !force) { this.optionsWrap.hide(); this.isShown = false; } else if (!this.isShown && false !== force){ this.optionsWrap.show(); this.isShown = true; } } Dropdown.prototype._AddShadow = function() { var shadowWidth = 5, layer; for (var i = 0; i < shadowWidth; i++) { layer = $('<div class="shadow_layer"> </div>'); layer.css({ opacity: 0.055 * (i + 1), top: (shadowWidth - i), left: (shadowWidth - i), height: this.height, width: this.width }); this.optionsWrap.prepend(layer); } } Dropdown.prototype._SetEvents = function() { var self = this; this.el.bind('click', function(e) { var current = $(e.target); var type = current.attr("type"); if (current.hasClass('dropdown-text') || current.hasClass('dropdown-arrow')) { if (!self.isShown) { page.HideAllDropdowns(); } self.Toggle(); return false; } if (current.hasClass('dropdown-opt')) { switch (type) { case 'auto': case 'basic': var html = current.html(); self.handle.html(html); self.options.find('a.dropdown-opt').each(function() { $(this).removeClass('selected'); }); if ('auto' == type) { page.common.Update({ url: current.attr('path'), params: current.attr('params'), target: self.target, parent: true, method: "POST", handler: { handler: function(results) { var action = this.attr("action"); if (action) { page.events.Fire(action, this, results) }; }, context: current } }); } current.addClass('selected'); self.Toggle(); return false; case 'multi': current.toggleClass('selected'); break; case 'function': var html = current.html(); self.handle.html(html); current.Fire(); self.Toggle(false); break } } return false; }); } I don't want my sidebar columns to be too long when the main content is shorter. Is there any way (javascript? jquery? something else?) to only let certain divs load when the main content reaches a certain height?
I need javascript to read height of an static multiline text and write height value into the var value? Is it possible? please help me~~Hi I have to create a table using javascript. Firefox displays the expected result but for IE, the column width is screwed >"< I have to use the col tag to set width because sometimes the first row maybe merged. All I need is to create a table that strictly displays according to the inputted column widths from my program. In below I have setup very short example that construct table in a similar way to my original javascript function. I also draw a ruler to help showing the proper width of 400px on the screen. column 1 should be 100px width and column 2 should be 300px. Please help me~~T_T Code: <?xml version='1.0' encoding='UTF-8'?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <body onload="init()"> Hard Coded: <DIV style="WIDTH: 400px; HEIGHT: 25px;overflow:hidden;"> <TABLE style="border:none; BORDER-SPACING: 0px; WIDTH: 400px; TABLE-LAYOUT: fixed" cellSpacing="0" cellpadding="0"> <col width="100px"> <col width="300px"> <TBODY> <TR> <TD style="background-color:blue"> a </TD> <TD style="background-color:green"> b </TD> </TR> </TBODY> </TABLE> </DIV> Ruler: <div id='ruler' style="background-color:yellow;width:400px;height:28px;"></div> Javascript inserted: <div id="hi"> </div> </body> <script language="javascript"> function init() { var w = [100, 300] // test table create var testDiv, testTBody, testTable, testTr, testTd, testCol; document.getElementById("hi").appendChild(testDiv = document.createElement("div")); with (testDiv.style) { width="400px"; height="25px"; } testDiv.appendChild(testTable = document.createElement("table")); with (testTable) { style.tableLayout="fixed"; style.borderSpacing="0px"; style.width = "400px"; appendChild(testCol = document.createElement("col")); testCol.style.width = 100 + 'px'; appendChild(testCol = document.createElement("col")); //testCol.style.width = 300 + 'px'; appendChild(testTBody = document.createElement("tbody")); cellSpacing= 0 } testTBody.appendChild(testTr = document.createElement("tr")); with (testTr){ } for (var i= 0; i < 2; i++) { testTr.appendChild(testTd = document.createElement("td")); testTd.innerHTML = "Testing"; with (testTd) { style.borderTop = "1px solid lightgray"; style.borderLeft="1px solid lightgray"; style.borderRight="1px solid black"; style.borderBottom="1px solid black"; } } } </script> </html> Hello, I run a online gaming website, and I'm having problems with certain websites iframing our games. Actually I'm ok with iframing, as long as they include the banner ad located just beneath our games. But often times unscrupulous webmasters will iframe only the game, preventing us from generating any revenue from the banner ad (and costing us additional bandwidth charges). I'm hoping to find a way to detect the dimensions of the iframe, so that I may dynamically resize the game, in order to include the banner ad within the iframe. Does anybody know how to extract the "height" and "width" attribute values from an <iframe> tag sitting on a different site? Regards, Steve I've got a page (hrnewseastanglia.com) where I have to use a jquery function to stretch the body to the user's window height if it isn't already. In the same code I also use a condition that if the body is bigger than the user's window, the content has a padding to stop it going over the grass. The reason I need to do the resize is because I have a background image that needs to sit at the very bottom of the page (with no bar or gap below it). The reason the padding can only exist when the body is bigger than the window is because it will put a scrollbar on pages that shouldn't have them. It works great, but the only trouble is that if somebody decides to resize their window on a page that fits in it - it breaks. This is my script: Code: <script type="text/javascript"> $(document).ready( function() { stretch_portal_content(); $(window).resize( stretch_portal_content ); }); function stretch_portal_content() { // if the body isn't at least as big as the user's window - force it to be if( $(window).height() > $('body').height() ) { $( '#wrapper' ).height( $(window).height() - ( $('body').height() - $('#wrapper').height() ) ); } // if the content goes beyond the window make sure it doesn't go beyond the grass at the bottom if( $(window).height() < $('#wrapper').height() ) { $( '#wrapper' ).css("padding-bottom", '130px'); } } </script> I've been scratching my head over this for hours but haven't come up with a solution. If anyone can help I'd really appreciate it! I was told by Kunena developers that the issue is that when I insert an image or a video in my forum, it is loading after javascript loads setting the height to "static". Unfortunately they didn't know a fix, so I came here I guess the script is causing the forum articles to overflow the height by exactly the same number of pixels as the image/video. When the page is reloaded, the issue is corrected, but its really annoying for visitors who don't know to reload the page. Not to sound like a big dummy or anything, but I have gone through every file in my template and have found absolutely no "static" scripts, so any help in tracking it down would be greatly appreciated as I am not a javascript guru. I have tried preloading the images, but it had no effect. An example of the overflow issue can be found here https://christian-knowledge.com/inde...id=22&id=25#25 At the moment I have changed the overflow value on that particular section to "auto" to get around it for the time being, but its definitively not a good fix. Thank you for your time and I really appreciate any assistance or advice on how to fix this Hi there. I'm relatively new to coding in javascript, so I'm hoping that some kind souls could help me out! I'm trying to make an animated image height changer (example: changing an image's height from 50px to 500px). I'm working on a new web site using HTML5 and want to add some Flash-like animation to my page using javascript and <canvas>. The animation would only need to "play" one time once the web page has loaded. No looping is required and no user interaction (ie mouseovers, etc) is needed. Any help would be greatly appreciated. If anyone knows of similar examples online please send me a link. If you're interested in helping, please let me know if more information is needed. Thanks. Hello! I am playing with CSS3 transitions to show/hide a DIV element. The application will be for a newsletter which will allow a user to show and hide article content. There will be multiple articles. I have a <DIV id="article1" class="content"> and the default height is 0px. When someone clicks the "show/hide article" link I set the height to 250px. A CSS transition on the content class (height) adds a smooth change from 0px to 250px. I have rigged up a simple Javascript function so that when someone clicks the "show/hide article" link, it checks the height of the DIV. If the div is 0px, it should expand the content, if not, it should shrink it. It works when you click the link the first time (i.e. the content div height is set to 250px and the transition works). But when you click it again, it does not set the height to 0px in order to hide the content. I think there is something wrong with the validation of document.getElementById(articleID).style.height ? Any ideas? Thank you! Code: Code: <!DOCTYPE html> <html land="en"> <head> <script language="javascript" type="text/javascript"> function showhideContent(articleID) { if(document.getElementById(articleID).style.offsetHeight = '0px'){ document.getElementById(articleID).style.height = '250px'; } else{ document.getElementById(articleID).style.height = '0px'; } } </script> <style type="text/css"> p { margin:10px; font-size:12px; } h1 { margin:10px; } body { background-color:lightgrey; font-family:Arial; font-size:12px; } #newsletter { width:500px; border:solid; border-width:1px; border-color:black; background-color:white; text-align:left; font-size:11px; } #header { height:125px; } #footer { height:50px; background-color:#330033; } #headerbar{ background-color:lightblue; height:35px; overflow:hidden; font-size:12px; -webkit-transition: background-color 1s; } #headerbar:hover{ background-color:#3399FF; } .content{ background-color:white; height:0px; overflow:hidden; -webkit-transition: height 0.5s ease-in-out; } #expand{ background-color:red; } </style> </head> <meta charset="UTF-8"> <body> <center> <div id="newsletter"> <section id="header"> <img src="newsletter_header_test.jpg"> </section> <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam sed turpis augue, nec cursus metus. Proin dictum, velit vel vulputate vulputate, ante sem iaculis risus, at faucibus nibh tellus et ante. Vivamus quis enim nec arcu dictum molestie non quis ipsum. <br><br> Proin vel mi eget sapien tincidunt pretium et non eros. Nullam vitae lacus at tortor volutpat feugiat. Vivamus venenatis risus in urna aliquet laoreet tempus diam consequat. Praesent viverra placerat venenatis. Quisque arcu nisl, congue sed blandit ut, suscipit eu velit. Nam quam massa, sollicitudin et elementum at, tempus nec eros. Etiam eget tortor condimentum metus accumsan dignissim eu sed sem. </p> <article> <section id="headerbar"> <div style="float:left;"> <h1>Introducing: the first article</h1> </div> <div style="float:right;"> <p> <a id="expand" href="#" onClick="javascript:showhideContent ('article1');return false;">Show/Hide Article</a> </p> </div> </section> <div> <section id="article1" class="content"> <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam sed turpis augue, nec cursus metus. Proin dictum, velit vel vulputate vulputate, ante sem iaculis risus, at faucibus nibh tellus et ante. Vivamus quis enim nec arcu dictum molestie non quis ipsum. <br><br> Proin vel mi eget sapien tincidunt pretium et non eros. Nullam vitae lacus at tortor volutpat feugiat. Vivamus venenatis risus in urna aliquet laoreet tempus diam consequat. Praesent viverra placerat venenatis. Quisque arcu nisl, congue sed blandit ut, suscipit eu velit. Nam quam massa, sollicitudin et elementum at, tempus nec eros. Etiam eget tortor condimentum metus accumsan dignissim eu sed sem. Quisque ultricies volutpat mauris, nec cursus <br><br> sapien laoreet ut. Maecenas volutpat porta enim et tincidunt. Sed vel lectus eget dolor dictum ultrices in in mauris. Praesent laoreet velit vitae est vulputate a varius lorem eleifend. </p> </section> </div> </article> <br> <br> <section id="footer"> <p>footer</p> </section> </div> </center> </body> </html> I want to create a table in javascript with a predefined height and width and put html code in its td. I wanna know when i should stop writing html code when my table have reached the predefined height. Is there any way to do that? I started by doing this : var srcTable = document.createElement("table"); srcTable.border = 1; srcTable.borderColor = "Black"; srcTable.height = 768; srcTable.width = 1024; var tmpRow = null; var tmpCell = null; for (i = 0; i < rowCount; i++) { tmpRow = AppendRow(srcTable) for (j = 0; j < colCount; j++) { tmpCell = AppendCell(tmpRow); tmpCell.innerHTML = document.getElementById("div").innerHTML; tmpCell = null; } tmpRow = null; } The html code in "div" element is way big then 768 px. I wanna know how to loop over and break it when table reaches 768 px height. |