Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-14-2012, 11:12 PM   PM User | #1
Taro
Regular Coder

 
Taro's Avatar
 
Join Date: Oct 2011
Location: Geraldton, Ontario
Posts: 155
Thanks: 1
Thanked 1 Time in 1 Post
Taro is an unknown quantity at this point
Post zooming in script on button press

Hello,

I've been working on creating a script that zooms the entire webpage. Other than using "CTRL" + "+" keys (generally compatible with all browsers) to zoom in inside a web browser, I want to put it in a different format, as a button; it would be even easier to use.

The problem is that I can't figure out how to make it work/ why it does not work. The following is my code:

Code:
<html>
<head>
<script type = "text/javascript">

document.onkeydown = function(zoomin) {
var key;
zoomin = zoomin || event;
key = zoomin.keyCode;
key == 43;
return false;

if (key == 17) {
return true;
function(zoomin){;
return false;
}

}
}</script>
</head>
<body>
<h1>Is this appearing to get bigger?</h1>
<button onclick="javascript: function('zoomin');">Zoom in</button>

</body>
</html>


Basically I was trying to use a DEC code as the code for the "CTRL" and "+" keys; then put them into a function. The "return true" under the IF statement means that I want it to hold so that the "+" key can be read as part of the script, and therefore make the page zoom in. Once that happens, it returns false.

I would appreciate any help/ suggestions. I will also try to look for a way to reset the page (100%) or zoom out as well.
__________________
Element ID

Webs Support Helper

Your friendly neighborhood Taroman.
Taro is offline   Reply With Quote
Old 03-15-2012, 12:47 AM   PM User | #2
devnull69
Senior Coder

 
Join Date: Dec 2010
Posts: 2,245
Thanks: 10
Thanked 530 Times in 524 Posts
devnull69 will become famous soon enough
This cannot possibly be your code, can it?

1. A comparison with no depending command like if/while etc?
Code:
key == 43;
2. An anonymous function inside another function that will never be called?
Code:
function(zoomin){;
return false;
}
3. The semicolon on the first line of this code is not wrong, but highly unusual ...
4. Also in the button onclick you are only defining an anonymous function without calling anything

Bottom line: You need to learn more about functions, function references and functions calls
devnull69 is offline   Reply With Quote
Reply

Bookmarks

Tags
browser, javascript, small, zoom

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:31 PM.


Advertisement
Log in to turn off these ads.