Toon posts:

Javascript variable vraag

Pagina: 1
Acties:

Verwijderd

Topicstarter
Weet iemand hoe ik een variable die in javascript staat:

<script>

height= 10;
</script>

dan weer kan gebruiken in html ?

<table height=%height>

zoiets ??

  • Janoz
  • Registratie: Oktober 2000
  • Laatst online: 12-09 21:31

Janoz

Moderator Devschuur®

!litemod

Javascript hoort in /13

een manier is om de tag door javascript te laten schrijven:
code:
1
2
3
<script>
document.write("<table height="+height+">");
</script>

Ken Thompson's famous line from V6 UNIX is equaly applicable to this post:
'You are not expected to understand this'


  • Nazgul
  • Registratie: Februari 2000
  • Laatst online: 11-10-2022

Nazgul

Digital Pizza Crew

Meer een vraagje voor onze buren in /13, maar heb dit gevonden:
Using JavaScript entities, you can specify a JavaScript expression as the value of an HTML attribute. Entity values are evaluated dynamically. This allows you to create more flexible HTML constructs, because the attributes of one HTML element can depend on information about elements placed previously on the page.
You may already be familiar with HTML character entities by which you can define characters with special numerical codes or names by preceding the name with an ampersand (&) and terminating it with a semicolon (; ). For example, you can include a greater-than symbol (>) with the character entity &GT; and a less-than symbol (<) with &LT;.

JavaScript entities also start with an ampersand (&) and end with a semicolon (; ). Instead of a name or number, you use a JavaScript expression enclosed in curly braces {}. You can use JavaScript entities only where an HTML attribute value would normally go. For example, suppose you define a variable barWidth. You could create a horizontal rule with the specified percentage width as follows:


<HR WIDTH="&{barWidth};%" ALIGN="LEFT">

No trees were killed in the sending of this message. However a large number of electrons were terribly inconvenienced.


Verwijderd

Topicstarter
hoe dan een javascript var in een
layer te plaatsen die in html staat?
zeg
<Script>
height=10
</script>
<body>
<html>
<DIV style="position : 0;width : 30; height : &{height}";
?

  • wasigh
  • Registratie: Januari 2001
  • Niet online

wasigh

wasigh.blogspot.com

javascript
P&W --> W&G

  • crisp
  • Registratie: Februari 2000
  • Nu online

crisp

Devver

Pixelated

Op maandag 18 februari 2002 11:22 schreef Nazgul het volgende:
Meer een vraagje voor onze buren in /13, maar heb dit gevonden:
[..]
Bijzonder interessant; echter heb ik het even uitgetest hier met IE5.0 en het werkt dus gewoon niet. Misschien een NS(4)-only dingetje?
Ook heb ik het vermoeden aangezien ze het over HTML attributen hebben dat het ook niet voor inline CSS opgaat...

Intentionally left blank


  • cutter
  • Registratie: November 2000
  • Laatst online: 28-09-2025

cutter

Wannabe i7 fanboy

Misschien is dit een aardig startpunt om je javascript capaciteiten tot ontwikkeling te brengen.
http://directory.google.com/Top/Computers/Programming/Languages/JavaScript/?tc=1

http://www.webwareindex.com/tutorials/Javascript.html
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
    <title>Untitled</title>
</head>

<body onload="table.height=700">
<FORM>
    <SELECT onChange=
    "table.height=this.options[this.selectedIndex].value">
      <OPTION VALUE="400"> 400
      <OPTION VALUE="500"> 500
      <OPTION VALUE="600"> 600
      <OPTION VALUE="700" SELECTED> 700
    </SELECT>
</FORM>
<table bgcolor="black" id="table">
<tr>
    <td>Niets te zien gewoon voor de breedte</td>
</tr>
</table>
</body>
</html>

Dit soort dingen leer je dan....

Verwijderd

table.style.height :X ;)

  • cutter
  • Registratie: November 2000
  • Laatst online: 28-09-2025

cutter

Wannabe i7 fanboy

Op maandag 18 februari 2002 12:09 schreef Cheatah het volgende:
table.style.height :X ;)
:X Hij's trouwens ook niet NS compatible maar IE doet ie het prima, ging bij de weg ook om het idee. Zie het als een nette manier van UTFS roepen. ;)

  • Nazgul
  • Registratie: Februari 2000
  • Laatst online: 11-10-2022

Nazgul

Digital Pizza Crew

Op maandag 18 februari 2002 11:56 schreef crisp het volgende:

[..]

Bijzonder interessant; echter heb ik het even uitgetest hier met IE5.0 en het werkt dus gewoon niet. Misschien een NS(4)-only dingetje?
Ook heb ik het vermoeden aangezien ze het over HTML attributen hebben dat het ook niet voor inline CSS opgaat...
Klopt, het &{naam}; principe is Javascript (NS) en geen Jscript (IE)
Maar hij vroeg toch ook om een Javascript oplossing. >:)

Verder is de height attribuut die hij als voorbeeld gebruikt een HTML attribuut en geen inline CSS attribuut, ook al zou dat naar mijn weten ook gewoon voor inline CSS moeten werken. (Heb hier geen NS tot mijn beschikking om het te testen.)

No trees were killed in the sending of this message. However a large number of electrons were terribly inconvenienced.

Pagina: 1