aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Controlling applet element using javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Controlling applet element using javascript" Watch "Controlling applet element using javascript" New topic
Author

Controlling applet element using javascript

Peter Lager
Greenhorn

Joined: Nov 10, 2012
Posts: 6

I have a web page with an applet (using object tag) inside a div region which can be seen [url=http://www.lagers.org.uk/temp/applet/indexjs_2.html here[/url].

The problem I have is that the Java layout for the applet is fixed size but when using the mouse wheel to zoom in/out of the webpage the 'applet area' increases and what I want to enforce a maximum size.

I have posted the page source inside the body tags below. Sorry about the length but the resize stuff is near the end.


Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4658
    
    5

Peter Lager wrote:The problem I have is that ...


The problem you have is trying to use applets. Why are you trying to use an applet in 2013? Applets are dead technology. See the discussion at http://www.coderanch.com/t/572824/Applets/java/interest-lots-questions-applets
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

If you're saying that in this line of code



you don't want the value of the applet_height variable to increase without limit, then simply precede it with some code which enforces that rule.

Or is that not the question?
Peter Lager
Greenhorn

Joined: Nov 10, 2012
Posts: 6

The applet I have created is a fixed size 660px by 420px and when the browser zoom is 1.0 then it sets aside an area 660px x 420px which is good. Now when the mouse wheel is used to zoom in then it increases the area set aside for the applet. So if the zoom level is 2 it sets aside 1320x840px but I want this area to remain as 660x420px.

The applet object has an id 'myapplet' and the div id is 'AppletDiv' and the code in size_changed is my effort to control the applet size
  • by changing the applet_height and applet_width variables depending on the zoom level (r.zoom)


  • use javascript to set the myapplet and AppletDiv objects with



  • This is my first effort to use JavaScript in a meaningful way so a lot of what I am doing is hack and see so any suggestions are welcome.

    Thanks for reading.
    Paul Clapham
    Bartender

    Joined: Oct 14, 2005
    Posts: 18570
        
        8

    Obviously there's something I'm missing here, because if I wanted something to have a size of 660 by 420 px, I would just style it to have that size and not do anything else.

    Perhaps it's that "browser zoom" concept I'm missing. What is that anyway?

    And as far as I can see the question has nothing at all to do with applets (except that it happens to be an applet that you're trying to style). I'm going to move the thread to the forum about Javascript.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Controlling applet element using javascript