473,799 Members | 3,866 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Stuck in hell, surrounded by font elements

Somehow font elements are being added everywhere in my page, with size
set to 4. Maybe I'm just tired but I have no idea what's going on, even
weirder considering the page is XHTML 1.0 strict served with the proper
MIME type... heres some code:

var divs = document.getEle mentsByTagName( "div");
for (var i=0; i<divs.length; i++) {
if (divs[i].className == "cwindow") {
windows.push( [ divs[i].title, document.body.r emoveChild(divs[i])]
);
i--;
}
}

for (var i=0; i<windows.lengt h; i++) {
bodytext += "<div class='window_b order'><div class='window_w rap'><div
class='window_h eader'><div class='window_h eader_content'> ";
//Title
bodytext += windows[i][0];
bodytext += "</div></div><div class='window_b ody_border'><di v
class='window_b ody' style='backgrou nd-position:" +(
Math.round(Math .random()*800) )+ "px " +( Math.round(Math .random()*800)
)+ "px;'>";
//Body
bodytext += windows[i][1].innerHTML;
bodytext += "</div></div></div></div>";
}

Wherever I add the title and body from 'windows' it puts it inside a
font element with size of 4. Text is huge. It also adds it in other
places in the middle of a string asigned with innerHTML. I don't get it
and I'm giving up for sleep now, please point out my simple stupid
mistake.

HS

Nov 12 '06 #1
9 1432
ASM
ho**********@gm ail.com a écrit :
Somehow font elements are being added everywhere in my page, with size
set to 4. Maybe I'm just tired but I have no idea what's going on, even
weirder considering the page is XHTML 1.0 strict served with the proper
MIME type... heres some code:
That bellow works fine for me :

<div class="cwindow" ><h1>One</h1></div>
<div class="cwindow" >Two</div>
<div class="other">< span style="color:bl ue">for</span></div>
<div class="cwindow" ><span style="color:re d">five</span></div>

<script type="text/javascript">
var divs = document.getEle mentsByTagName( "div");
var windows = new Array();
var bodytext='';
for (var i=0; i<divs.length; i++) {
if (divs[i].className == "cwindow") {
windows.push([divs[i].title, document.body.r emoveChild(divs[i])]);
i--;
}
}

for (var i=0; i<windows.lengt h; i++) {
bodytext += "<div class='window_b order'><div class='window_w rap'>"+
"<div class='window_h eader'><div class='window_h eader_content'> ";
//Title
bodytext += windows[i][0];
bodytext += "<\/div><\/div><div class='window_b ody_border'><di v "+
"class='window_ body' style='backgrou nd-position:" +
(Math.round(Mat h.random()*800) )+ "px " +
( Math.round(Math .random()*800)) + "px;'>";
//Body
bodytext += windows[i][1].innerHTML;
bodytext += "<\/div><\/div><\/div><\/div>";
}
document.body.i nnerHTML = bodytext;
</script>

Wherever I add the title and body from 'windows' it puts it inside a
font element with size of 4. Text is huge. It also adds it in other
places in the middle of a string asigned with innerHTML.
it would have been better to cloneNode(true) the divs 'cwindow'
Nov 12 '06 #2


On Nov 12, 2:09 am, hobosales...@gm ail.com wrote:
Somehow font elements are being added everywhere in my page, with size
set to 4. Maybe I'm just tired but I have no idea what's going on, even
weirder considering the page is XHTML 1.0 strict served with the proper
MIME type... heres some code:

<fonthas a tendency of cascading down the entire dom if it isn't
closed or is put in odd places.
ie: wrap a table in a <fontand all the <td>'s get <fontinserted
into them. It is incredibly annoying.

Nov 12 '06 #3
Unbelievable, the problem was a forum admin that thinks he's a web
designer. He added <font size=4to a forum category, without closing
it, so it ended up applied to most of the page. It was hard to track
down because it was hiding in an SQL database. So, sorry for wasting
bandwidth with what was really a non-javascript issue.

ASM wrote:
it would have been better to cloneNode(true) the divs 'cwindow'
Is there a difference between cloning and removing, and just using the
return value from removeChild()? I know that removing elements from a
list while stepping through it is maybe not so bright, but in this case
I don't see the problem?

HS

Nov 12 '06 #4
Richard Levasseur wrote:
<fonthas a tendency of cascading down the entire dom if it isn't
closed or is put in odd places.
ie: wrap a table in a <fontand all the <td>'s get <fontinserted
into them. It is incredibly annoying.
Oh boy is it ever....

It's inspired me to write a perl script that looks through a site for
pages with a valid XHTML doctype , and adds deprecated markup in random
places.

HS

Nov 12 '06 #5
ho**********@gm ail.com wrote:
it would have been better to cloneNode(true) the divs 'cwindow'

Is there a difference between cloning and removing, and just using the
return value from removeChild()? I know that removing elements from a
list while stepping through it is maybe not so bright, but in this case
I don't see the problem?
I was giving this more thought, and wouldn't it be more efficient to
use the returned value from removeChild(), than the extra memory
involved in a deep copy of the element only to remove it anyway?

HS

Nov 12 '06 #6
ASM
ho**********@gm ail.com a écrit :
ho**********@gm ail.com wrote:
>>it would have been better to cloneNode(true) the divs 'cwindow'
Is there a difference between cloning and removing, and just using the
return value from removeChild()? I know that removing elements from a
list while stepping through it is maybe not so bright, but in this case
I don't see the problem?
As I found no problem in my test with inneHTML, I can't say more.
I was giving this more thought, and wouldn't it be more efficient to
use the returned value from removeChild(), than the extra memory
involved in a deep copy of the element only to remove it anyway?
As I don't understand what you try to do ...
Tacking content of divs of class 'something' to put it in others divs of
class 'something-else' ...

Why not to append directly the divs of class 'something' after having
changed this class in 'something-else' in your group of others divs (I
don't know their use)
<div class="cwindow" title="un">
<h1>One</h1>
</div>
<div class="other" title="number 2">
<span style="color:re d">two</span>
</div>
<div class="cwindow" title="trois">
<font size="6" color="maroon"> Three</font>
<tt>three</tt>
</div>
<div class="other">
<span style="color:bl ue">for</span>
</div>
<div class="cwindow" title="red span">
<span style="color:re d">five</span>
</div>
<script type="text/javascript">

function newDiv(classe) {
var D = document.create Element('div');
D.className = classe;
return D;
}

var divs = document.getEle mentsByTagName( "div");
for (var i=0; i<divs.length; i++) {
if (divs[i].className == "cwindow") {
var R = newDiv('window_ border');
var S = newDiv('window_ wrap');
var T = newDiv('window_ header');
var U = newDiv('window_ header_content' );
U.innerHTML = divs[i].title;
T.appendChild(U );
S.appendChild(T );
T = newDiv('window_ body_border');
divs[i].className = 'window_body';
divs[i].style.backgrou ndPosition =
(Math.round(Mat h.random()*800) )+ "px " +
( Math.round(Math .random()*800)) + "px";
T.appendChild(d ivs[i]);
S.appendChild(T );
R.appendChild(S );
document.body.a ppendChild(R);
}
}
</script>

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Nov 12 '06 #7
ASM wrote:
As I don't understand what you try to do ...
Tacking content of divs of class 'something' to put it in others divs of
class 'something-else' ...

Why not to append directly the divs of class 'something' after having
changed this class in 'something-else' in your group of others divs (I
don't know their use)
I was thinking more theoretically, but I have PHP generated divs which
are content for "windows", which javascript removes from the page so
that a loader screen can appear while the rest of the HTML and JS is
downloaded, then it creates windows and adds the content from the
original page. I can't append directly to the other div because it
doesn't exist yet.

Nov 13 '06 #8
ASM
ho**********@gm ail.com a écrit :
ASM wrote:
>As I don't understand what you try to do ...
Tacking content of divs of class 'something' to put it in others divs of
class 'something-else' ...

Why not to append directly the divs of class 'something' after having
changed this class in 'something-else' in your group of others divs (I
don't know their use)

I was thinking more theoretically, but I have PHP generated divs which
are content for "windows", which javascript removes from the page so
that a loader screen can appear while the rest of the HTML and JS is
downloaded, then it creates windows and adds the content from the
original page. I can't append directly to the other div because it
doesn't exist yet.
No, I understood your displayers groups of divs don't exist, in what I
suggested these groups are created each time it is necessary.
Of course, you can make a function to do all that job; this function
being launched after complete loading of the php file.
Appending on the fly directly in groups the targeted divs one by one is
equivalent to move them one by one (no need to remove and remember all
them)

onload = function() {
var divs = document.getEle mentsByTagName( "div");
for (var i=0; i<divs.length; i++)
if( ... etc ...
}
But that will not fix the problem of absent font closing tag :-)

Is tag 'font' allowed in XHTML 1.0 strict ?

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Nov 13 '06 #9
ASM wrote:
Is tag 'font' allowed in XHTML 1.0 strict ?
Noooooo... it's like taking a 1982 Toyota Corolla with blown rings and
missing catalytic converter in for an emissions test. The font tag is
evil, useless, obsolete, and only used by amateurs that don't know any
better (like my users apparently).

HS

Nov 14 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
9564
by: Csaba2000 | last post by:
How do I detect when the font size has been changed (especially by user action: either Ctrl+Scroll wheel or View/Text Size)? This is just for use on IE 5.5+, but it would be great if there was a generic solution. Thanks, Csaba Gabor from New York
7
6808
by: Phil Powell | last post by:
Code: <!-- script src="/js/val_header.js"></script --> <style> <!-- BODY { scrollbar-3d-light-color:#eeeedd; scrollbar-arrow-color:#000000; scrollbar-base-color:#000000; scrollbar-dark-shadow-color:#eeeedd;
4
16725
by: Csaba Gabor | last post by:
What I'd like to do is to be able to set the font of a textarea element to the same font that another element is using (say, for example, an <INPUT type=text ...> element, but if that's a no go, then a generic element's font will do OK, too. What's the correct way to do this, please (so that it will also work for IE 6)? The motivation for this is that I have some text on the screen and I want to insert a textarea element between the...
9
3780
by: Dr John Stockton | last post by:
Assuming default set-ups and considering all reasonable browsers, whatever that may mean, what should an author expect that his readers in general will see (with visual browsers) for a page with body like <br><br> Abc <font size=+1> Abc <font size=+1> Abc <font size=+1> Abc <font size=+1> Abc <font size=+1>
16
2459
by: maya | last post by:
I have heard so much preaching here about how font sizes should be set as percentages so users can change font-sizes on their browsers... ok, so now at work am working on a site where we need to do precisely that b/c it's for an audience that some users maybe be visually-impaired.. but I can't get it to work right, problem is that font sizes are not consistent across diff elements.. code: body {text-align:center; /* to center...
18
25007
by: Diogenes | last post by:
Hi All; I, like others, have been frustrated with designing forms that look and flow the same in both IE and Firefox. They simply did not scale the same. I have discovered, to my chagrin, that IE7 does not seem to offer any way to control the font size of a text input element.
8
2079
by: scrm | last post by:
Hi there - I've just redesigned my site (http://scandal.org ) as a simple photo gallery. I'm having some trouble getting it to display as I'd like on IE (7.0, Win). I'd like your advice on a few points: 1) Positioning The design is very no-frills: 750px fixed width, a centred photo with a logo on the top left, navigation menu on the top right, a link to the photo's Flickr page on the bottom left, and a footer graphic on the bottom...
14
2830
by: Roedy Green | last post by:
Is there a shortcut way to define the default font family (and characteristics) to be applied to all styles? -- Roedy Green Canadian Mind Products The Java Glossary http://mindprod.com
0
9687
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10257
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10237
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10029
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7567
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6808
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3761
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.