•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 427,377 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,038 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 775 | Replies: 1
![]() |
•
•
Join Date: Feb 2008
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
I need help I am pretty new to JavaScript... I try my best at it but I am getting lost and need some help.
What I want to do is grab an elements width and height and apply it to a window or a popup window.
In my case this is what currently have and I can't seem to get any further.. thanks in advance.
What I want to do is grab an elements width and height and apply it to a window or a popup window.
In my case this is what currently have and I can't seem to get any further.. thanks in advance.
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
var contentHTML = "Couldn't find content";
function popup(obj) {
var contentName = obj.parentNode.childNodes;
for (var i=0; i<contentName.length; i++) {
if (contentName[i].tagName != undefined) {
contentHTML = contentName[i].innerHTML;
break;
}
}
var winPopup = writeConsole();
writeConsole('<div id=\"placeHolder\"></div>');
function writeConsole(content) {
top.consoleRef=window.open('','placeHolder',
'width=350,height=250'
+',left=500'
+',top=300'
+',menubar=0'
+',toolbar=0'
+',status=0'
+',scrollbars=0'
+',resizable=1')
top.consoleRef.document.writeln(
'<html><head><title>Content Pop-Up</title><script type=\"text/javascript\" language=\"JavaScript\">var timerDelay; function showIt(){document.getElementById(\'placeHolder\').innerHTML = window.opener.contentHTML; timerDelay = window.setTimeout(\"window.print()\",1000);}<\/script></head>'
+'<body onLoad="showIt()">'
+content
+'</body></html>'
)
top.consoleRef.document.close()
}
}
</script>
</head>
<body>
<div>
<div>
<table width="400" border="1" cellspacing="0" cellpadding="0">
<tr>
<td>Content1</td>
</tr>
</table>
</div>
<input type="button" value=" Show " onclick="popup(this)">
</div>
<br />
<br />
<div>
<div>
<table width="600" border="1" cellspacing="0" cellpadding="0">
<tr>
<td>Content2</td>
</tr>
</table>
</div>
<input type="button" value=" Show " onclick="popup(this)">
</div>
</body>
</html>•
•
Join Date: Jan 2008
Location: Bangalore, India
Posts: 336
Reputation:
Rep Power: 0
Solved Threads: 32
to grab element width & height use:
clientWidth clientHeight method on element it returns the viewable width/height of the content on the page, not including borders, margins, or scrollbars
or use
offsetWidth/offsetHeight -returns the width/height of the element, including borders and padding if any, but not margins
clientWidth clientHeight method on element it returns the viewable width/height of the content on the page, not including borders, margins, or scrollbars
or use
offsetWidth/offsetHeight -returns the width/height of the element, including borders and padding if any, but not margins
A computer lets you make more mistakes faster than any invention in human history - with the possible exceptions of handguns and tequila.
~Mitch Ratcliffe
~Mitch Ratcliffe
![]() |
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
access activation api blogger blogging blogs code combo cross-browser javascript menu with few lines of code dani daniweb data debugging development dreamweaver dropdownlist equivalent code of messagebox in asp.net gdata google gpl html innovation key linux microsoft module net news openbsd product programming reuse rss serial setting datalist repeatcolumn property dynamically so that the datalist has a fixed height source tags vista web wysiwyg xml
- Previous Thread: Create table 1 to 100 using java script
- Next Thread: Calling a PHP file from a javascript code


Linear Mode