Very Simple Yet Effective Text Zoom Function
Feb 15, 2008
As part of a school project I had the main body of text at 11px, some people could read it, some couldn't, and so I created a zoom function. Unlike the normal zoom functions in JS or the browser's own zoom, which increase the size of everything thus throwing some areas out of proportion, mine only increases the size of the main body of text.
(using php tags to get code highlighting)
<table>
<tr><script type="text/javascript">
var px = new Array(11,12,13,14,15,16,17,18,19,20,21,22,23); // insert your own numbers here, these are the font sizes - goes as higher or as low as you want. If the number is less than the original font size you have yourself a zoom-out function too.
var size = 0;
function do_change_down(elemID) {
if (size > 0) {
size--
document.getElementById(elemID).style.fontSize = px[size]
}
}
function do_change_up(elemID) {
if (size < 12) { // number is how many elements in the px array. if there are more elements in the array, it will not use them all, it'll stop at that number, so make sure you increment it when you add more to the array.
size++
document.getElementById(elemID).style.fontSize = px[size]
}
}
</script>
<td>
<label for="zoom">Change font size: </label><a href="javascript:do_change_down('text')" id="zoom" name="zoom">-</a> <a href="javascript:do_change_up('text')" name="zoom" id="zoom">+</a>
</td>
</tr>
</table>
in this instance I have the main content area with the id="text" - change the do_change_down('your_element_id'); and same for do_change_up accordingly to the text you want to be 'zoomed' in on..
As it says in the title, this is a very simple function but is also very effective.
View 2 Replies
ADVERTISEMENT
Mar 28, 2011
I am trying to use a user defined function and text area for a project, but nothing is showing up in the text area when i click the button.
View 5 Replies
View Related
Nov 4, 2010
On google maps I have several hundred markers for different countries and cities across the globe. It is just not practical to navigate through several hundred markers therefore I would like my browser to auto navigate to predefined multiple latitudes and longtitudes or cities, once the navigation for predefined cities completes, the navigation loop carries on. Also for certain cities or latitude / longitude can we set zoom level so when the browser is auto navigating it zooms in and zooms out for predefined cities. Is this possible, here is the code that I am using.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title/>Apache-Geo-Map Example</title>
<script src="http://maps.google.com/maps?file=api&v=2&key=<my-api-key>"
[Code].....
I can see several hundred markers on the map, rather than navigating between each marker I would like my browser to auto navigate through predefined cities with auto zoom in and zoom out values.
View 3 Replies
View Related
Dec 14, 2011
I was not happy with the zoom scripts that I found on the net, so I wrote one myself, or one that simulates it. It has become an extremely simple one, and can be seen in action here (function toggleZoom). Click the images to zoom in and click to zoom out again.However, only the images with an initial width of >= 100 pixels will zoom out again. The ones width an initial width of < 100 (nrs. 4, 5 and 7) won't. Why is that, and how do I solve it?
View 2 Replies
View Related
Oct 4, 2009
I want text links to swap the image on the website, but then want to allow a zoom function or lightbox function to the image that appears. I'm not best at explaining things so i've done an example below. After clicking the link, the image changes. i want to be able to do the zoom on the image that it's changed to.
View 1 Replies
View Related
Feb 1, 2011
i m using the below code to disable ctrl+ and ctrl- (zoom in/out using keyboard). The below code is working in firefox but it is not working in IE. The return false; is not working in IE. can you please some one help in this?
$(document).ready(function()
{
var ctrlDown = false;[code].....
View 3 Replies
View Related
Mar 31, 2010
I have seen a website that has a great image zoom function and would like to be able to add this function to my website. I'm afraid my Javascript isn't very good. where I can get a script to do this or how else if there is some free software that could do it? The webpage is: http:[url].....On this page if you click on Zoom on the left another image comes up on the right and when you mouse over the square on the left image it zooms the right image.
View 3 Replies
View Related
Jul 26, 2007
I want to build simple comment box. It will containt text box, few smilies and view pictures for inserting tags like , , like in vBulletin and phpBB.
When user clicks on smile, script adds something like "" or "" into text box. I wonder what is simpliest way to do this?
View 6 Replies
View Related
Aug 10, 2009
On the page, a person will select an item on a drop down menu, and this automatically updates two spans of text.In one span of text, I've included simple text inputs. I'd like to use Radio Buttons, but the script doesn't seem to operate unless its a text input.I've included the parts of the script that will effect the other span of text, but I don't see how that would be important to you, so I've left those portions in a faint-ish grey.Here is the script...
<script type="text/javascript">
function UpdateHistoryText(sel)
{
[code]....
View 10 Replies
View Related
Jan 31, 2002
I have a form, and I want two text input fields to be disable by default, in HTML, it's something like:
<input type="text" name="" value"" disabled />
And when a user selects a picticular radio button, it re-enables those two text input, if the user chooses another radio button, those two text input gets disable again.
I suppose JS can do that, can someone please show me a way of doing it?
View 2 Replies
View Related
Mar 27, 2010
I have used the below code, found on a forum from 2006, to generate a random image on my website with a link and accompanying text.The image works fine, the link that goes with each image is fine.Problem is: the text beneath the image does not match the image and link. This seems to be generated as a separate random element. Can anyone tell me how I can make my site display image 1 + link 1 + quotation 1?
View 6 Replies
View Related
Nov 29, 2009
I need to make a very simple text scroller (either vertical or horizontal) using JavaScript.
View 3 Replies
View Related
Jul 23, 2005
Can this be refined further to be more efficient?
function shout()
{
if (isNaN(document.form1.entry.value)==true) {
alert("please only enter numbers for an answer")}
else
{
alert("the new number is: "+(+document.form1.entry.value+5))}
}
also what would be the correct structure as to make the script more legible
to regular and proficient writers of JS?
View 7 Replies
View Related
Jun 9, 2009
I'm trying to write a function that does a simple math function between some textfields.
There are 4 variables : Unit price, Discount, Quantity and Total
Unit price is a fixed variable.
Discount, Quantity and Total depend on the fixed variable and also on the values of eachother. (ie : if qty=2 then total=2xUnit Price) etc...
I want to be able to show the changing values in real time.
So if I have 3 textfields and I change qty, I want it to update Total based on the discount and the qty. If I update discount, I want to update Total based on qty and discount.
I'm guessing I would have to write three functions and call each one from their respective textfields.
How to write a function, and call it so that passes the unit price to the funtion, gets the values of all of the textfields and then changes them all to their new values?
View 15 Replies
View Related
Nov 18, 2010
I am trying to make a simple trim function but this doesnt works.
function tr(input){
var i;
var str;
for(i=0; i<input.length-1; i++){
if(text.charAt(i)==" "){
str+=""+text.charAt(i)
} return str
}}
View 4 Replies
View Related
Jul 6, 2009
I have a simple function defined on my page in the script section that should put me in a div named "apDiv4" a text when i press the down arrow in a text input called 'search2'. But it does nothing.
Here's the function:
And here is where i call it:
Why this doesn't work? I've tried onkeydown= "KeyCheck()" too.
View 5 Replies
View Related
Oct 18, 2009
I need to create a simple calculator in Java. Below is what I have so far; it is not working currently and I'm not sure why. I also needed to add the parseInt function somewhere in the code but I'm not sure where.
import java.util.Scanner;
public class CalcDemo {
public static void main(String[] args){
}
private int valueA;
private int valueB;
private String operator;
private char operatorA;
public int getvalueA() {
return valueA;
} .....
View 2 Replies
View Related
Jan 14, 2007
I am a Javascript newbie and I'm trying to implement a very simple form validation function, but for some reason it won't work. I must be doing something fundamentally wrong here. Maybe somebody can hint me into the right direction? My code looks like so:
function validate_form ()
{
valid = true;
var re = new RegExp();
re.compile("[A-Za-z0-9._-]+@[^.]+..+");
if ((document.form.author_name.value == "")
|| (document.form.author_email.value == "")
|| (!re.test(document.form.author_email.value))
|| (document.form.author_message.value == ""))
{
alert ("Please fill in all required fields.");
valid = false;
}
return valid;
}
The tricky bit is the email validation using the regular expression. Apart from that it all works.
View 3 Replies
View Related
Nov 16, 2010
Don Gosselin's JavaScript Fourth Edition is a tiresome read and I have been unable to put together the necessary tools that Don teaches to find the answers that I want to make the following function work.
function calculate()
var shipping = 0;
var total = 0; {
if (document.forms[0].hand_tool.value != document.forms[0].hand_tool.value == true)
(document.forms[0]item1.value == 20); {
[Code]...
View 3 Replies
View Related
Apr 8, 2009
The following is a simple form with text boxes..Used java script to check for nulls but how to check my phone number for only integer values ie numbers
View 2 Replies
View Related
Dec 23, 2010
Been racking my brain all day trying to figure out how to duplicate this code with the limited javascript knowledge I have been trying to learn.This code is a Dropdown menu of Yes or No, than a Select button that Opens up a Text Input directly below the dropdown. So far, It works great. My problem is I need at least two of these on the same page and I do not know how to go about it. I have tried changing values to accommodate adding another on the same form, but than both stop working.
<html>
<head>
<SCRIPT language="javascript">
[code]...
View 5 Replies
View Related
Aug 26, 2011
Im using this javascript plugin on my website and i try to figure it out how to make the shop link work - when i click on shop i want to load another page directly. I'm a new in webdesign (actually this is my first website) and i think that i should change the script.. so take a look at my page source.
View 2 Replies
View Related
Oct 12, 2010
I am doing a simple slidetoggle with a click function. Meaning I am basically sliding a div (content) into nothing with another div (button) using a click event. This works all fine and dandy but now here is the problem.. I want to change the class of the div(button) so that I may show a different background image depending on the state of the open or closed content div.
Here is the code so far...
$(document).ready(function() {
$('.Button').click(function() {
$('.Content').slideToggle('normal');
if($(this).next().is(':hidden') == false) {
$(this).addClass('off');
alert ('You should see See More button.');
}});
Then obviously I have CSS that has the classes I need including an "on" class that I could not get to fire.
View 4 Replies
View Related
Jan 21, 2009
I am trying to write a simple javascript function that locates a parameter in a url, if it is present, and replace it with a different value. Here's my code:
function setParam(url,param,value) {
var a = '&'+param+'=d+';
var new_url = url.replace(new RegExp(a), '');
new_url = new_url + '&'+param+'='+value;
return new_url;
}
The problem is, it doesn't work. It adds the new param, value pair to the old url, but the old param isn't replaced. What do I need to do here to make this work?
View 2 Replies
View Related
Jul 6, 2010
I am trying to do a simple echo onclick, but despite what I try to do, it shows no errors, but won't work. I've tried things like:
echo "<div onclick="alert('test');">t</div>";
echo '<div onclick="alert('test');">t</div>';
But just can't seem to get it to work right. I'm trying to do this on a script that is being eval on the ajax request. Thus I'm having problems placing the ',", marks.
View 7 Replies
View Related
Nov 23, 2010
I want to write a function that appends a text string to my div. It seems pretty straight forward and I can't figure out why this doesn't work.
<html>
<head>
<script type="text/javascript">
[code]....
View 6 Replies
View Related