0

I am trying to change the horizontal positioning of an applet by changing the hspace attribute depending on the screen resolution. The Javascript below does not seem to change anything:

<html>
<body>

<applet 
    id="clientApplet"
    archive="client.jar" 
    code="Client.class" 
    width="500" height="530"
    hspace="100">
</applet>

<br />

<script type="text/javascript">
    var leftMargin = (screen.width-500)/2;

    document.getElementById("clientApplet").setAttribute(hspace, leftMargin);

    window.location.reload()
</script>

</body>
</html>

Can anyone tell me where I am going wrong please?

1 Answer 1

1

hspace needs to be a string:

document.getElementById("clientApplet").setAttribute("hspace", leftMargin);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.