Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 19th, 2005, 06:33 AM
Registered User
 
Join Date: Jan 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default use a JS-variable/function inside a tag

Hi!

I want to display an applet in a html page. I want to have it the maximum size, so that it exactly fits into the browser, without scrollbars.

To achieve this, I'm thinking of the following solution. Two javascript functions return the width and the height of the available area. This is no problem. However, I want to use these values in the WIDTH and HEIGHT attributes of the APPLET tag. Something like:

<script language="javascript" type="text/javascript">
function pageWidth() {return window.innerWidth .. ;}
function pageHeight() {return window.innerHeight .. ;}
</script>

<APPLET CODE=TheApplet.class HEIGHT=??? WIDTH=???>

How can I do this? Is there a way to use a javascript variable or -function inside a tag?

T.I.A.

 
Old January 19th, 2005, 08:27 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

You might look at using the style setting alongside the expression syntax, see dynamic properties:
http://msdn.microsoft.com/library/de...iew/recalc.asp

Alternatively set the applets attributes, give the applet an id:
Code:
var oApplet = document.getElementById(<appletId>);
oApplet.width = pageWidth();
//...
You might want to use the document.body.clientWidth.


--

Joe (Microsoft MVP - XML)
 
Old January 19th, 2005, 04:29 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Remember to make this cross-browser compliant. window.innerWidth is a Netscape property, and document.body.clientWidth is the Microsoft version.

Also remember that the expression syntax is IE-only.

hth,

-Snib - http://www.snibworks.com
Where will you be in 100 years?
 
Old January 20th, 2005, 05:42 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Quote:
quote:Originally posted by Snib
 Remember to make this cross-browser compliant. window.innerWidth is a Netscape property, and document.body.clientWidth is the Microsoft version.

Also remember that the expression syntax is IE-only.

hth,

-Snib - http://www.snibworks.com
Where will you be in 100 years?
Too true, painfully. I sometimes forget that I'm in an all IE environment which can be annoying from some points of view but makes development quicker...

Netscape used to have the a better version of "expression" where you could use javascript entities in attributes, I'm not sure if they still work however.

--

Joe (Microsoft MVP - XML)





Similar Threads
Thread Thread Starter Forum Replies Last Post
'FormView' must be placed inside a form tag stephena.co.uk ASP.NET 2.0 Basics 2 October 15th, 2008 08:25 AM
Printing the content inside the div tag cheeky Pro JSP 0 April 26th, 2007 07:26 AM
asp inside js crmpicco Classic ASP Basics 2 July 6th, 2005 09:49 PM
Prb with js function call inside flash using XSL schander10 XSLT 3 September 14th, 2004 07:33 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.