473,387 Members | 1,548 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,387 software developers and data experts.

old newspaper issue, javascript answer?

:o)
Does anyone know a (better) way to automatically adjust "newspape
style" columns to window-resize? See old discussion o
stylesheets-forum:
http://www.forum4designers.com/showt...light=newspape
-
:o

Jul 23 '05 #1
11 1901
:o) wrote:
Does anyone know a (better) way to automatically adjust
"newspaper style" columns to window-resize? See old
discussion on stylesheets-forum:
http://www.forum4designers.com/showthr ...

<snip>

forum4designers.com is not a forum it is a web-based access to Usenet
system, and an extremely poor, dishonest and incomplete one at that
(best avoided at all costs).

Richard.
Jul 23 '05 #2
On Tue, 13 Jul 2004 15:17:08 GMT, :o) wrote:
http://www.forum4designers.com/showt...ight=newspaper


Intriguingly, also available on usenet,..
<http://google.com/groups?thl=0,961403397,961396737,961293589,9610026 54,960992120,960987870,960980759,960984439,9607448 32,960697766,960984700>

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
Jul 23 '05 #3
Fox

":o)" wrote:

Does anyone know a (better) way to automatically adjust "newspaper
style" columns to window-resize? See old discussion on
stylesheets-forum:
http://www.forum4designers.com/showt...ight=newspaper
--
:o)

Older versions of Netscape [since v3, i think] had an html tag called
multicol that would flow text in newspaper-like columns... it is
deprecated and no longer available in more "standards compliant"
browsers [mozillas] and never was available in IE:

<multicol
width=1200
cols = 8
gutter=15

....
</multicol>

width and gutter in px values. A 1200 wide layout divided by 6 columns
results in a column 200 minus gutter width.

If you still have NN4.x, here's a demo:

http://fxmahoney.com/demo/multicol.htm

otherwise, don't bother. You can't really style this tag -- anything
like borders results in one long column... background colors results in
a "highlighting" effect and layer-background-color simply does not
work... font characteristics, however, do work (including line-height,
and text-align: justify!!!). BTW, this tag works better on a Mac than on
a PC - Macs will display bolded text, whereas PC's won't.

It's too bad this tag basically died...it really needed a chance for
further development.

Fox
*************
Jul 23 '05 #4
:o)
Thanks Fox, I'm aware of multicol and all that. The question is whethe
there is a scripting workaround, such as the one in the previou
attachment. This scirpt seems to do the trick under IE6, but it'
terribly slow, compared with web-sites as www.refdag.nl and www.iht.co
that use resizable multicolumn lay-out already. Cheers
-
:o

Jul 23 '05 #5
Andrew Thompson wrote:
<snip>
Intriguingly, also available on usenet,..
<http://google.com/groupsthl=0,961403397,961396737,
961293589,961002654,960992120,960987870,960980759,
960984439,960744832,960697766,960984700>


In their ongoing effort to deserve their reputation as the worst
provider of web based access to Usenet, forum4designers have re-produced
your message on their web site without the body text or the google URL.

Richard.
Jul 23 '05 #6
:o) wrote:
<snip>
... , such as the one in the
previous attachment. ...

<snip>

Attachments are explicitly forbidden in comp.lang.javascript (see the
FAQ), it is a plain text only newsgroup. As such many new servers do not
accept, or propagate, attachments associated with this group so the
majority of the people reading your posts probably will not see one
anyway.

Incidentally, your news posting software appears to be defective in that
it is not sending References headers with messages that appear to be
intended as follow-ups to an existing message. In addition the Lines
header is erroneously reporting 1 in a message that clearly has multiple
lines. You should correct these faults or find alternative posting
software (adequate software is available free of charge for most OSs).

Richard.
Jul 23 '05 #7
On Wed, 14 Jul 2004 18:56:09 +0100, Richard Cornford wrote:
Andrew Thompson wrote:
<snip>
Intriguingly, also available on usenet,..
.... In their ongoing effort to deserve their reputation as the worst
provider of web based access to Usenet.. <bleep> .. have re-produced your message on their web site
without the body text or the google URL.


LOL. for'em four designers? What absolute losers!

[ and ftr 'groups . google . com' is but
one possible alternative ]

...and they can stick that up their
'intuitive, web-based interface'
Jul 23 '05 #8
:o
Apologies to you all; getting to the grips with this. The attached file is on

http://www.geocities.com/myjavascrip...lticolTest.htm

and pasted below:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>test</TITLE>
<SCRIPT>
function make_columns(){
document.body.style.backgroundColor = "black"
var columnWidth = 200
var columnHeight = document.body.clientHeight-100
var columnGap = 20

var x = document.getElementById("stuff")
var i = 0
var k = 0

while(k<x.childNodes.length){
var new_column = document.createElement("div")
new_column.style.position = "absolute";
new_column.style.left = i*(columnWidth+columnGap)+50+"px";
new_column.style.top = 50+"px";
new_column.style.width = columnWidth+"px";
new_column.style.color = "white";
new_column.style.fontSize = "8pt";
new_column.style.fontFamily = "verdana, arial, helvetica, sans-serif";
new_column.style.lineHeight = "9pt";
new_column.style.padding = "3px";
new_column.style.textAlign = "justify";
document.body.appendChild(new_column)

if(i==0){
var c = x.childNodes[k].nodeValue
var b = document.createElement("div")
b.innerText = c.substring(0,1)
b.style.color = "white"
b.style.fontSize = "40pt"
b.style.height = b.style.fontSize.split("pt")[0]/2+"pt"
b.style.fontFamily = "verdana, arial, helvetica, sans-serif"
b.style.float = "left"
b.setAttribute("align","center")
new_column.appendChild(b)
c = c.substring(1,c.length)
x.childNodes[k].nodeValue = c
}

new_column.innerHTML = new_column.innerHTML+""

while(new_column.offsetHeight<columnHeight&&k<x.ch ildNodes.length){
node_clone = x.childNodes[k].cloneNode(true)
new_column.appendChild(node_clone)
k++
}

if(new_column.offsetHeight>columnHeight){
k--
if(node_clone.nodeType!==3)
var cnode = node_clone.childNodes[0]
else
var cnode = node_clone
if(cnode.nodeType!==3) alert("cnode is geen tekst node!")

var indx,ccnode
var dd = ""
while(new_column.offsetHeight>columnHeight){
indx = cnode.nodeValue.lastIndexOf(" ")
if(indx==-1) {
dd = cnode.nodeValue+dd
cnode.nodeValue = ""
}
else {
cnode.splitText(indx)
ccnode = cnode.nextSibling
dd = ccnode.nodeValue+dd
cnode.parentNode.removeChild(ccnode)
}
}

if(node_clone.nodeType!==3)
x.childNodes[k].childNodes[0].nodeValue = dd
else
x.childNodes[k].nodeValue = dd

var b = document.createElement("span")
b.style.visibility = "hidden"
b.innerText = " someverylongword"
new_column.appendChild(b)

i++
}
}
}
</SCRIPT>
</HEAD>
<BODY onresize=window.location.reload() onload="make_columns();return false;">
<DIV id=stuff style="DISPLAY: none">Lorem ipsum dolor sit amet, consectetuer
adipiscing elit. Vestibulum nisl leo, faucibus varius, venenatis quis, faucibus
non, pede. Aliquam diam eros, fringilla ut, gravida ut, bibendum non, erat.
Aliquam porttitor faucibus justo. Morbi justo nisl, euismod vel, tincidunt at,
sagittis et, sapien. Vestibulum ante ipsum primis in faucibus orci luctus et
ultrices posuere cubilia Curae; Nullam scelerisque elit. Nullam dictum, arcu sit
amet adipiscing sodales, felis arcu sagittis odio, eget mattis mi leo sit amet
augue. Nulla sit amet wisi ac eros ornare molestie. Vivamus luctus tellus in
diam. Nullam lacinia massa vitae augue. Maecenas iaculis, nibh eu accumsan
tempus, dolor sapien volutpat lacus, sed semper felis pede at diam. Pellentesque
libero mauris, consequat non, imperdiet eu, egestas nec, dui. In ut leo. Nullam
mattis commodo justo. Donec est. Integer bibendum viverra felis. In porttitor
nibh vitae lorem. Pellentesque porttitor. Sed vestibulum, nulla eu euismod
consectetuer, magna dolor commodo sem, id nonummy erat ipsum a nulla. Fusce
laoreet magna nec sem. Proin sagittis odio vitae odio. Suspendisse potenti.
Mauris sit amet lacus. Maecenas quam. Pellentesque habitant morbi tristique
senectus et netus et malesuada fames ac turpis egestas. Morbi mauris tortor,
dignissim sit amet, elementum quis, mattis at, quam. Phasellus varius orci.
Pellentesque venenatis, diam et suscipit porttitor, mi massa porta tortor, a
dignissim ante neque quis massa. Morbi viverra dolor. In vitae dolor vitae
sapien molestie tincidunt. Integer eu eros. Duis vel nisl nec felis fringilla
tempor. Sed porttitor. Morbi et sem quis arcu porta rhoncus. In at arcu sed
mauris interdum convallis. Proin adipiscing commodo mi. Ut vestibulum augue
vitae arcu. Suspendisse lacus erat, facilisis vitae, dapibus eget, aliquam non,
libero. Ut sem. Praesent fringilla est quis erat. Duis nec quam. Vestibulum sed
eros lacinia ante faucibus fermentum. Etiam ac orci non pede fermentum
porttitor. Mauris dolor nulla, vestibulum egestas, consectetuer non, sodales in,
velit. Curabitur blandit eros non sem. In mi sem, semper id, tempor nec,
hendrerit vitae, nisl. Phasellus diam leo, varius vel, pretium sed, elementum
commodo, odio. Curabitur vitae justo cursus justo iaculis fringilla. Cras ligula
eros, cursus et, ornare et, tristique non, tellus. Nam non diam. Morbi mauris
justo, nonummy sit amet, ultrices id, consectetuer et, justo. Quisque non ipsum.
Aenean lacus felis, vulputate in, dignissim pulvinar, scelerisque eget, wisi.
Aenean lectus mauris, egestas ac, sollicitudin at, cursus in, ligula. Mauris
adipiscing, ipsum eget tincidunt convallis, magna dolor consequat lacus, vitae
pretium mi massa sit amet pede. Donec et nibh eget ligula facilisis vulputate.
Ut sodales dui nec metus. Quisque vitae dui. Proin rhoncus suscipit dolor. Sed
aliquam. Sed ipsum erat, placerat non, dignissim vitae, rutrum non, purus. Donec
vel erat. Vestibulum pharetra, risus vel facilisis euismod, mi urna feugiat
nibh, eu mollis erat lectus eget odio. Proin ipsum felis, laoreet a, consequat
vel, laoreet ut, nibh. Sed consequat, nisl a accumsan bibendum, metus arcu
iaculis magna, ut commodo erat lorem quis massa. Pellentesque habitant morbi
tristique senectus et netus et malesuada fames ac turpis egestas. Aliquam felis.
Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos
hymenaeos.
</DIV></BODY></HTML>
Jul 23 '05 #9
:o wrote:
^^
Who?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
The system identifier is missing to make that Valid HTML.
See comp.infosystems.www.authoring.html.
<HTML><HEAD><TITLE>test</TITLE>
<http://www.w3.org/QA/Tips/good-titles>
<SCRIPT>
This "script" element lacks the "type" attribute which is mandatory:

<script type="text/javascript">
function make_columns(){
document.body.style.backgroundColor = "black"
You do not check for the DOM of the UA before you use it.
This is error-prone:

<http://pointedears.de/scripts/test/whatami>
var columnWidth = 200
var columnHeight = document.body.clientHeight-100
See above.
var columnGap = 20

var x = document.getElementById("stuff")
See above.
var i = 0
var k = 0

while(k<x.childNodes.length){
You do not check if `x' is a valid object reference before
you access its supposed properties, and you do not check
if those properties are references before you refer to them.
See above.

And a C-style for-loop would IMHO suit much better here and
further below.
var new_column = document.createElement("div")
new_column.style.position = "absolute";
Same here about not checking anything prior to access.
new_column.style.left = i*(columnWidth+columnGap)+50+"px";
new_column.style.top = 50+"px";
new_column.style.width = columnWidth+"px";
new_column.style.color = "white";
new_column.style.fontSize = "8pt";
Do not use "pt" for font size outside of stylesheets for printing.
Default font resolution on display devices differs between screen
resolutions, graphics servers and platforms which most certainly
renders a pt-sized font legible on one system but illegible on
many others. Use "px" or "em" instead.
new_column.style.fontFamily = "verdana, arial, helvetica, sans-serif";
new_column.style.lineHeight = "9pt";
The same here. Use "em" for line-height (1em = default height),
not "pt".
new_column.style.padding = "3px";
new_column.style.textAlign = "justify";
Again, nothing is checked for. And it is unperformant to look up
a reference repeatedly:

var s;
if ((s = new_column.style))
{
if (typeof s.left != "undefined")
{
s.left = ...;
}
...
}
document.body.appendChild(new_column)
[...]
See above.
new_column.innerHTML = new_column.innerHTML+""
`innerHTML' ist a property of proprietary DOMs. To rely on it while
using standards compliant DOM Level 1+ methods just because the
programmer's favorite UAs support both is utter nonsense. See above.
[...]
var indx,ccnode
var dd = ""
while(new_column.offsetHeight>columnHeight){
indx = cnode.nodeValue.lastIndexOf(" ")
if(indx==-1) {
dd = cnode.nodeValue+dd
cnode.nodeValue = ""
}
else {
cnode.splitText(indx)
ccnode = cnode.nextSibling
dd = ccnode.nodeValue+dd
cnode.parentNode.removeChild(ccnode)
}
}
This indentation is hardly legible. And tab characters should not be
used for indentation since they are interpreted differently on different
devices.
if(node_clone.nodeType!==3)
x.childNodes[k].childNodes[0].nodeValue = dd
else
x.childNodes[k].nodeValue = dd
Same here.
var b = document.createElement("span")
b.style.visibility = "hidden" b.innerText = " someverylongword"
new_column.appendChild(b)
`innerText' is a proprietary property of the IE 4+ DOMs only. It is
not present in other DOMs and thus the script will work only in IE, UAs
based on it (using its browser component) or imitating its behavior
(namely possibly Opera).

DOM Level 3 Core provides the Node interface with a standards compliant
textContent attribute. It is available in recent versions of
Mozilla/5.0; a user-defined serialization method must be used for other UAs.
i++
}
}
See above.
}
</SCRIPT>
</HEAD>
<BODY onresize=window.location.reload()
This is invalid HTML and thus very likely to fail. The characters "("
and ")" must not occur in unquoted attribute values. As there are more
exceptions to this rule that maybe are hard to keep in mind, attribute
values should be quoted always, using single or double quotes (in XHTML
this is mandatory).
onload="make_columns();return false;">
What do you think that returning `false' to the onload handler would
do? This is but an example of further scriptkiddie coding, that is,
to use programming patters without thinking, often because of a lack
of a minimum clue.
<DIV id=stuff style="DISPLAY: none">Lorem ipsum [...]
</DIV></BODY></HTML>


You could have posted the source code with less example text.
Bandwidth is a precious good and must not be wasted. Some
people even pay for every additional byte they cause to be
transmitted to/from their machines.
PointedEars
Jul 23 '05 #10
:o
Thanks PointedEars; some polishing up to do to make it cross-browser
(and PointedEars) friendly, but it was never intended to work on
anything but my browser.

Looking forward to a thoughtful scriptadult coding that has the same
functionality, namely client-side rendering of a piece of HTML into
columns; which was the main question, really.

:o
Jul 23 '05 #11
On Wed, 14 Jul 2004 18:56:09 +0100, Richard Cornford wrote:
Andrew Thompson wrote:
<snip>
Intriguingly, also available on usenet,..
<http://google.com/groupsthl=0,961403397,961396737,
961293589,961002654,960992120,960987870,960980759,
960984439,960744832,960697766,960984700>


In their ongoing effort to deserve their reputation as the worst
provider of web based access to Usenet, forum4designers have re-produced
your message on their web site without the body text or the google URL.


It seems they are rather challenged at
rendering Geocities URL's as well..

<http://www.forum4designers.com/showthread.php?s=1301e7e77a60221c26bb6d3abb8ca0da& threadid=95672&perpage=10&pagenumber=2>
Let us see if they can reproduce their
*own* URL reliably..

Grrr. I would prefer people post URL's,
but it does not help having these 'web-based
interfaces' butcher the links.

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
Jul 23 '05 #12

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

Similar topics

5
by: Brandons of mass destruction | last post by:
Ok, I work for a small newspaper thats looking to translate our content to the web. XML sounds like a good way to do this, but i'm a little confused. Is it possible to have <b> and <i> tags in...
14
by: Adam Smith | last post by:
Hello, I've been trying to figure out how the columnar newspaper page layout is achieved in web pages, say at http://home.netscape.com/ or http://home.netscape.com/ . With the solid vertical &...
4
by: VB Programmer | last post by:
I have an ASPX page that I'm creating. It'll have alot of text. I want the text to be 2 columns, like a newspaper. If the user resizes the browser the columns should adjust accordingly. What...
5
by: Dave | last post by:
Is there a way to divide a datagrid into "newspaper" style columns so that column 1 would have rows 1-10, column two would have rows 11-20 etc? Thanks, Dave.
3
by: Muhammad Mustafa | last post by:
hello every body i have been searched and searched for any script in php that enable me to run asite of weekly news paper but i didn't find any :( all scripts i found enables you to divide the...
2
by: Mufasa | last post by:
I have a list of items that I'd like to have wrap like columns in a newspaper. So that as I add items, it would be in two columns and things would wrap appropriately. So if there were 11 items, it...
2
by: LayneMitch via WebmasterKB.com | last post by:
Hello. This is a basic quiz. Only about 3 questions. I'm having issue with the answer key which stays on a certain value regardless of acknowledging that you have the correct answer for the...
1
by: bumble | last post by:
Hi Everyone I have very little knowledge of Javascript or any other language and have built the basics of my website using Dreamweaver. I have built in extra functions just by trying to follow the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.