473,396 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Determine dimensions of rendered xhtml using javascript?

12
I'm using a WYSIWYG HTML editor that supports vertical and horizontal scrolling. I want to limit the area that users can edit. My editor doesn't support this so I need to come up with some way to determine the rendered dimensions of the XHTML.

I figure the easiet way to do this will be to extract the XHTML when it's updated using javascript and check if the rendered size is larger than I have specified. If it is I can use undo method in the editor or some other sort of notification.

How can I find the rendered dimensions of some xhtml using javascript? (I'm working in .Net2)
Oct 6 '07 #1
3 1718
pbmods
5,821 Expert 4TB
Heya, T0mm0. Welcome to TSDN!

You can limit the displayed size of an element very easily by using CSS. Simply give the element a specific width and height, then set its overflow property to 'hidden'.

To determine the size of an element, access its offsetWidth and offsetHeight attributes.
Oct 6 '07 #2
T0mm0
12
maybe a better way to put it is this.... for example if a user entered the following into a textbox how would you determine the dimensions of the string when rendered as html?

[HTML]<p>
<table cellspacing="2" cellpadding="2" width="500" border="0">
<tbody>
<tr>
<td style="width: 330px"><img height="407" alt="" src="http://www.swapmeetdave.com/Humor/Cats/CatLaugh.jpg" width="343" border="0" /></td>
<td style="width: 98px; height: 369px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp; </td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td><img height="400" alt="" src="http://www.fw.delaware.gov/NR/rdonlyres/7D197C78-ACFE-4497-8E3A-DAE2F4B3B545/385/FWDanielleDogLicense.jpg" width="300" border="0" /></td>
</tr>
</tbody>
</table>
</p>[/HTML]
Oct 8 '07 #3
T0mm0
12
solution was that in order to render the html that the wysiwyg editor was generating it had to do so in a document object of it's own... just worked out the api to the editor and found the document within it and the scrollwidth of that.
Oct 15 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: TheKeith | last post by:
I don't know much about javascript, so take it easy on me. Is there a way to dynamically change a CSS layers dimensions on the fly. Here is what I'm doing. I have a bunch of thumbnails that when...
6
by: Jonny | last post by:
How can you validate Javascript generated HTML for XHTML 1.0 strict compliance? To avoid the "<" and "&" problem, all inline scripts MUST be enclosed with either: <!-- script --> Looked down...
5
by: John | last post by:
I am rotating images at one location of my web site. My problem is if I set the width and height of the new image before I show the new image, the old image is stretched first to the new image...
3
by: Ernst | last post by:
I have a script for a menu. However, this menu uses absolute coordinates. This menu had to be placed on a website. This website is position (centered) using a table. How can I determine/calculate...
7
by: Kersh | last post by:
I'm trying to implement XHTML standards in my ASP.NET web pages but whenever I use web controls I get problems because of the very strict nature of W3C XHTML (transitional version is picky but...
9
by: Joris De Groote | last post by:
Hi, I'm looking for a javascript that can give me the screensize of a computer. Can anyone help me? Thanks
3
by: funstercinsolata | last post by:
--- This is my simple default.aspx: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0...
6
by: amaragraps | last post by:
Dear thescripts Experts, I have converted my large wavelets page http://www.amara.com/current/wavelet.html from HTML into XHTML and CSS and have one large remaining bug. On Safari and Opera...
10
dj12345
by: dj12345 | last post by:
Hi, (Asp.net + Ajax) I am creating a page which will fetch data from server without postbak of a page.. I have 2 controls on this page TextBox and Lable. I have assigned TextBoxWatermark...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.