[javascript] Zoveelste pop-up resize script...

Pagina: 1
Acties:

  • EelCapone
  • Registratie: December 2000
  • Laatst online: 09-07 09:00

EelCapone

Ik kom je halen!

Topicstarter
Ik heb dus een javascriptje geschreven om een pop-up windowtje te maken waarin foto's worden weergegeven, en dat ie 'em nadat de foto is geladen automatisch resized naar de groote van de foto...
Maar dat resizen werkt dus niet.. Ik heb al op een aantal sites gezocht, maar ik kom dr niet uit :'(
Kan iemand me helpen?

---[ popupfoto.js ]---
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function popupfoto(url)
{   var output = "";

    subwin = window.open("","fotowindow","scrollbars=no,resizable=yes,status=no,height=200,width=200");

    output += "<HTML>"
    output += "<head>"
    output += "<title>Eigen Huis In Puin</title>"
    output += "<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>"
    output += "<link rel='stylesheet' href='stylesheet.css' type='text/css'>"
    output += "<link rel='shortcut icon' href='images/eigenhuisinpuin.ico'>"
    output += "</head>"
    output += "<body bgcolor='#FFFFFF' text='#000000' leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'>"
    output += "<img border=0 src='"+url+"' name='foto1'>"
    output += "<script language='javascript'>"
    output += "document.resize(foto1.width,foto1.height);"
    output += "</script>"
    output += "</body>"
    output += "</html>"

    subwin.document.write(output);
    subwin.document.close();
}

Acorn BBC B [ 65C02@2MHz; 32k RAM; Solidisk Sideways 128k; Solidisk 1770 ADFS; Econet ]


  • crisp
  • Registratie: Februari 2000
  • Nu online

crisp

Devver

Pixelated

resize is een method van het window object; het moet dus window.resize() zijn. Verder kan je de hoogte en breedte van je plaatje pas uitlezen op het moment dat het plaatje volledig ingelezen is. Het beste kan je dus de resize in je onload event zetten:
code:
1
onLoad="window.resize(document.images['foto1'].width, document.images['foto1'].height)"

Intentionally left blank


  • EelCapone
  • Registratie: December 2000
  • Laatst online: 09-07 09:00

EelCapone

Ik kom je halen!

Topicstarter
Hmm ik heb er nu dit van gebakken, maar hij resized nog niet... Misschien is ut iets heel simpels, maar ik heb nog niet zoveel ervaring met JavaScript :)
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function popupfoto(url)
{   var output = "";

    subwin = window.open("","fotowindow","scrollbars=no,resizable=yes,status=no,height=200,width=200");

      output += "<HTML>"
      output += "<head>"
    output += "<title>Eigen Huis In Puin</title>"
    output += "<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>"
    output += "<link rel='stylesheet' href='stylesheet.css' type='text/css'>"
    output += "<link rel='shortcut icon' href='images/eigenhuisinpuin.ico'>"
    output += "</head>"
    output += "<body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0' onLoad='window.resize(document.images['foto1'].width, document.images['foto1'].height)'>"
    output += "<img border=0 src='"+url+"' name='foto1'>"
    output += "</body>"
    output += "</html>"

    subwin.document.write(output);
    subwin.document.close();
}

Acorn BBC B [ 65C02@2MHz; 32k RAM; Solidisk Sideways 128k; Solidisk 1770 ADFS; Econet ]


  • crisp
  • Registratie: Februari 2000
  • Nu online

crisp

Devver

Pixelated

ff gebruik van kwootjes aangepast, en resize gewijzigd in resizeTo; werkt perfect:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function popupfoto(url) {

  var output = '';
  subwin = window.open('','fotowindow','scrollbars=no,resizable=yes,status=no,height=200,width=200');

  output += '<html>';
  output += '<head>';
  output += '<title>Eigen Huis In Puin</title>';
  output += '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">';
  output += '<link rel="stylesheet" href="stylesheet.css" type="text/css">';
  output += '<link rel="shortcut icon" href="images/eigenhuisinpuin.ico">';
  output += '</head>';
  output += '<body style="margin: 0px; padding: 0px" onLoad="window.resizeTo(document.images[\'foto1\'].width, document.images[\'foto1\'].height)">';
  output += '<img border=0 src="'+url+'" name="foto1">';
  output += '</body>';
  output += '</html>';

  subwin.document.write(output);
  subwin.document.close();

}

:)

Intentionally left blank


  • Morrar
  • Registratie: Juni 2002
  • Laatst online: 31-08 12:55
Tis window.resizeTo(iW, iH) of window.resizeBy(iDW, iDH)... Wellicht dat dat helpt.

Suc6

edit:

Te laat...

Verwijderd

Zie bij :
[url="http://developer.irt.org/script/1300.htm"]http://developer.irt.org/script/1300.htm[/url]
[url="http://developer.irt.org/script/686.htm"]http://developer.irt.org/script/686.htm[/url]

  • EelCapone
  • Registratie: December 2000
  • Laatst online: 09-07 09:00

EelCapone

Ik kom je halen!

Topicstarter
Okeej, thanks! :)

Acorn BBC B [ 65C02@2MHz; 32k RAM; Solidisk Sideways 128k; Solidisk 1770 ADFS; Econet ]

Pagina: 1