JavaScript - Automatically Resize Divs
I have 3 divs (boxes) next to each other, I can input text via a textarea to each. I need all 3 to resize - be the same size on text overflow - so if box a gets 100 lines of code and resizes, the other 2 should follow. I have written this js, and added it to the button which moves the text to the boxes (to the onclick)
Code: // JavaScript Document function adjust() { if (document.getElementById('section1').style.height != 380 + "px") { document.getElementById('section2').style.height === document.getElementById('section1').style.height; document.getElementById('section3').style.height === document.getElementById('section1').style.height; } else if (document.getElementById('section2').style.height != 380 + "px") { document.getElementById('section1').style.height === document.getElementById('section2').style.height; document.getElementById('section3').style.height === document.getElementById('section2').style.height; } else if (document.getElementById('section3').style.height != 380 + "px") { document.getElementById('section1').style.height === document.getElementById('section3').style.height; document.getElementById('section2').style.height === document.getElementById('section3').style.height; } } any ideas what's wrong here? Similar TutorialsI'm not sure what this is called to google it, ok so i have 3 divs Code: <div id="div1"></div> <div id="div2"></div> <div id="div3"></div> Now say my page is 800x600 So when the page loads #div1 and #div3 height = 390px and #div2 height = 20px; What i want is when #div2 is draged it resized #div1 and #div3 E.G (#div2 is draged up so top = -100px) so when that happens i want #div1 = 290px and #div3 = 490px And vice versa now this is the code i have for my site So #div1 = ".torrents-list" #div2 = "#dragBar" #div3 = "#torrent_info" PHP Code: $("#dragBar").draggable({ axis: 'y', drag: function(event, ui){ var heightString= $("#dragBar").css("top"); var height = parseInt(heightString.replace("px", "")); $("#dragBar").css("top", "0px"); $(".torrent-list").height($(".torrent-list").height() + heightString); $("#torrent_info").height($("#torrent_info").height() - heightString); } }); But this dose not work for me its never setting #dragBar top to 0px and not resizing any thing if some one can tell me what this is called so i can google for a prebuilt one if not help me write one please? Hi' there Is there anyway to make a custom resize function that resizes one of my div elements on the webpage the same amount of pixels as the browser window gets resized? I have this slideshow, that twirls around but i'm trying to center it within the browser so the middle picture stays in the middle and the side pictures have about a 10px padding from the browsers border. The weird thing is that it adjusts itself when you first open the link, but if you have it open and resize your browser, it won't adjust to the width. Can't figure what i'm doing wrong. I already posted in the HTML/CSS forum but nobody could help. Thanks guys. Check it out he jonathaneiger.com hello .. i have some problem while while working on a script.. i want to use confirmation() function to confirm submit button and if its true ...then submit form... else keep on same page (thats logic) am using php as server scripting .. and i wrote ..in php PHP Code: <form action="del_cat.php\" name=\"myform\" method=\"post\"> "; Delete: <input type="submit\" name=\"delete\" onclick=\"confirmation()\" value=\"Delete\" > <br> Edit:<input type=\"submit\" name=\"edit\" value=\"Edit\" > </form>"; and used a javascript in head PHP Code: <script type="text/javascript\"> function confirmation() { var r=confirm(\"Are you ready to delete?\"); if (r==true) { document.myform.submit(); } else { alert(\"check twise before submitting \") } } </script> my problem is if i click "OK" or "Cancel" both case the form is automatically submitting ... see i used PHP Code: if (isset($_POST['delete'])) { mysql_query("DELETE FROM ********* WHERE id='{$_POST['cid']}'"); } this code to invoke the function .. I have a lightbox pop up on my homepage. I'm curious if there's a way to automatically close the pop up after 5 seconds or so. For some readon onClose kept popping in my head, but I'm pretty sure that's not correct. Thanks. Code: !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:// www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Lightbox Example</title> </head> <body> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/ libs/jquery/1.4/jquery.min.js"></script> <script type="text/javascript" src="/lightbox/ jquery.mousewheel-3.0.4.pack.js"></script> <script type="text/javascript" src="/lightbox/ jquery.fancybox-1.3.4.pack.js"></script> <link rel="stylesheet" type="text/css" href="/lightbox/fancybox/ jquery.fancybox-1.3.4.css" media="screen" /> <script type="text/javascript"> $(document).ready(function() { $("a#onload").fancybox({ 'frameHeight': 390, 'frameWidth': 640, 'hideOnContentClick': false, 'easingIn': 2000 }).trigger('click'); }); </script> <div id="lightbox_content" style="display:none"> <div id="data"> <img src="/lightbox/donate.jpg" alt="Support Today!"> <h1>Pledge Your Support Today!!</h1> </div> </div> <a id="onload" href="#data"></a> </body> </html> Is there some javascript that will make a link in a page be clicked on page load?
I'm no javascript expert, in fact i know very little. I Design wordpress themes in photoshop and I'm looking to add a little more "spice" to my themes using jQuery UI so i made a theme with this tabbed horizontal navigation with the sub menu showing horizontally under the menu when you hover over it. So i searched google on how to do this jQuery menu and got this. Code: <script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#main_nav li a.main").hover(function(){ $("#main_nav li a.main").removeClass("active"); $(this).addClass("active"); $(this).queue(function() { $(".sub_nav").fadeOut(); $(this).siblings(".sub_nav").fadeIn(); $(this).dequeue(); }); }); }); </script> The other part Code: <div class="menu"> <ul id="main_nav"> <li><a href="" class="main">ALL</a> <ul class="sub_nav"> <li><a href="">HOME</a></li> <li><a href="">NEWS</a></li> <li><a href="">ARTICLES</a></li> <li><a href="">PREVIEWS</a></li> <li><a href="">REVIEWS</a></li> <li><a href="">MEDIA</a></li> <li><a href="">GAME WIKI</a></li> <li><a href="">FORUMS</a></li> <li><a href="">SUBMIT CONTENT</a></li> <li><a href="">Journalist Pro</a></li> </ul> </li> <li><a href="" class="main">XBOX30</a> <ul class="sub_nav"> <li><a href="">HOME</a></li> <li><a href="">NEWS</a></li> <li><a href="">ARTICLES</a></li> <li><a href="">PREVIEWS</a></li> <li><a href="">REVIEWS</a></li> <li><a href="">MEDIA</a></li> <li><a href="">GAME WIKI</a></li> <li><a href="">FORUMS</a></li> <li><a href="">SUBMIT CONTENT</a></li> <li><a href="">Journalist Pro</a></li> </ul> </li> <li><a href="" class="main">PS3</a> <ul class="sub_nav"> <li><a href="">HOME</a></li> <li><a href="">NEWS</a></li> <li><a href="">ARTICLES</a></li> <li><a href="">PREVIEWS</a></li> <li><a href="">REVIEWS</a></li> <li><a href="">MEDIA</a></li> <li><a href="">GAME WIKI</a></li> <li><a href="">FORUMS</a></li> <li><a href="">SUBMIT CONTENT</a></li> <li><a href="">Journalist Pro</a></li> </ul> </li> <li><a href="" class="main">Wii U</a> <ul class="sub_nav"> <li><a href="">HOME</a></li> <li><a href="">NEWS</a></li> <li><a href="">ARTICLES</a></li> <li><a href="">PREVIEWS</a></li> <li><a href="">REVIEWS</a></li> <li><a href="">MEDIA</a></li> <li><a href="">GAME WIKI</a></li> <li><a href="">FORUMS</a></li> <li><a href="">SUBMIT CONTENT</a></li> <li><a href="">Journalist Pro</a></li> </ul> </li> <li><a href="" class="main">Wii</a> <ul class="sub_nav"> <li><a href="">HOME</a></li> <li><a href="">NEWS</a></li> <li><a href="">ARTICLES</a></li> <li><a href="">PREVIEWS</a></li> <li><a href="">REVIEWS</a></li> <li><a href="">MEDIA</a></li> <li><a href="">GAME WIKI</a></li> <li><a href="">FORUMS</a></li> <li><a href="">SUBMIT CONTENT</a></li> <li><a href="">Journalist Pro</a></li> </ul> </li> <li><a href="" class="main">PC</a> <ul class="sub_nav"> <li><a href="">HOME</a></li> <li><a href="">NEWS</a></li> <li><a href="">ARTICLES</a></li> <li><a href="">PREVIEWS</a></li> <li><a href="">REVIEWS</a></li> <li><a href="">MEDIA</a></li> <li><a href="">GAME WIKI</a></li> <li><a href="">FORUMS</a></li> <li><a href="">SUBMIT CONTENT</a></li> <li><a href="">Journalist Pro</a></li> </ul> </li> <li><a href="" class="main">VITA</a> <ul class="sub_nav"> <li><a href="">HOME</a></li> <li><a href="">NEWS</a></li> <li><a href="">ARTICLES</a></li> <li><a href="">PREVIEWS</a></li> <li><a href="">REVIEWS</a></li> <li><a href="">MEDIA</a></li> <li><a href="">GAME WIKI</a></li> <li><a href="">FORUMS</a></li> <li><a href="">SUBMIT CONTENT</a></li> <li><a href="">Journalist Pro</a></li> </ul> </li> <li><a href="" class="main">PSP</a> <ul class="sub_nav"> <li><a href="">HOME</a></li> <li><a href="">NEWS</a></li> <li><a href="">ARTICLES</a></li> <li><a href="">PREVIEWS</a></li> <li><a href="">REVIEWS</a></li> <li><a href="">MEDIA</a></li> <li><a href="">GAME WIKI</a></li> <li><a href="">FORUMS</a></li> <li><a href="">SUBMIT CONTENT</a></li> <li><a href="">Journalist Pro</a></li> </ul> </li> <li><a href="" class="main">DS</a> <ul class="sub_nav"> <li><a href="">HOME</a></li> <li><a href="">NEWS</a></li> <li><a href="">ARTICLES</a></li> <li><a href="">PREVIEWS</a></li> <li><a href="">REVIEWS</a></li> <li><a href="">MEDIA</a></li> <li><a href="">GAME WIKI</a></li> <li><a href="">FORUMS</a></li> <li><a href="">SUBMIT CONTENT</a></li> <li><a href="">Journalist Pro</a></li> </ul> </li> </ul> </div> </div> </div> I'm needing the first tab (the "ALL" tab) to be selected by default, but i don't have the first clue on how to do this. You can paste the code in notepadd++ and you can see what i mean. How are you guys? Is there a possible thing? I've got 16 pages, one for each of 16 days. Then I've got index page. Where will be mine usual stuff but I want to add 16 visible buttons and under each button will be its content, let say for example a picture with some text. I need automatically when user open mine index for example 3rd to show 3rd picture with some text. Is that possible? To be more specific. I need some content to be automatically changed from 1st of January 2010 to 17th of January 2010. I have a welcome message on my site and would like to automatically hide it after several seconds. I can't find anything usable after searching over the internet. Can anyone help? Thanks in advance. Hi,
I have a form in my site.when the form is submit successfully it's go to another page, which shows "submission is success".
and that page has a link to go back to a page which is viewing previously(before to form)
this is the code for it Code: <a href="javascript:history.go(-2)">Go back to previous</a> I want to know, how to go to previous page by automatically ??? this should be happen after 10 seconds! please help me.... Hi, I am trying to write a script to get my sprite to move to the next row once it reaches the last frame on it's current row. Here's my attempt so far; in the code below I want bird2 when it reaches frame 3 and spState(1) - this means first row - to switch to spState (2) second row. Code: if ($('#bird2'['current_frame']) == 3 && $('#bird2').spState(1)) { $('#bird2').spState(2); } else { $('#bird2').spState(1); } Here's the code regarding the spState() Code: spState: function(n) { $(this).each(function() { // change state of a sprite, where state is the vertical // position of the background image (e.g. frames row) var yPos = ((n - 1) * $(this).height()) + 'px'; var xPos = $._spritely.getBgX($(this)); var bp = xPos + ' -' + yPos; $(this).css('background-position', bp); }); return this; this is from http://www.spritely.net/ you will notice on this site that if you drag the slider to the left the bird sprites change direction, in fact they play the second row of frames. The reason I want my bird sprite to go automatically to the next row is because I am using video turned into individual frames and a png strip, and I am limited by the max width of png (8192px). see http://www.cranihum.com/ scroll down to see the bird on the rooftop. Each frame in that bird sprite is 80px wide and there are 93 frames. So I would like to include multiple rows to allow me to increase the number of frames. Up to 15 rows will be needed and after the last row it should go back to the first row. Perhaps a switch statement would be better than what I currently have. I am new to JavaScript and have been trying to pick up clues from http://www.w3schools.com I am very happy to learn and I hope to be prompted and pushed in the right direction. I hope my request is clear, please ask questions if not. Thank you Will Does anyone know of a good library/function that will add the commas to a number automatically as the number is entered into a field?
Hi there im trying to automatically time out a floating div window. So far have this which works when i preview in the server but not live on the site: Code: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1250"> <title>Floating Window</title> <script src="Drag.js"></script> </head> <body onload="setTimeout(function(){ document.getElementById('window').style.display='none'; },7000);"> <div id="window" style="position:absolute; overflow:hidden; z-index:10; left:0px; top:0px; width:100%; height:100%; background-color:#ffffff;"> <div align="center"><img src="site_logo.gif" width="700" height="100"></div> <div style="position:absolute; top:3px; left:95%; float:right;" onClick="this.parentNode.parentNode.style.display = 'none';"> <img src="close_button.gif" width="48" height="14" border="0"></a></div> <div align="center"><img src="interstitial.gif" width=700 height=373 alt="" border="0"></div> </div> </body> </html> the bit in red is the code thats not working/timing out after 7 seconds in the live site. the bit in blue is the code that does close the window but only if you click the close button. Ive also tried inserting something like this: <script type="text/javascript"> function nodeHide() { this.parentNode.parentNode.style.display = 'none'; } window.onload = setTimeout("nodeHide()", 7000); </script> but i just get errors.... I also tried this: <script type="text/javascript"> <!-- function nodeHide(){ this.parentNode.parentNode.style.display = "none" } //--> </script> </head> <body OnLoad = "setTimeout('nodeHide()', 7000)"> but i get an error saying this.parentNode.parentNode. is null or not an object. any help you could give would be great! Lisa hello all member help me quick i am create a one form in 10 texbox. i am copy other web Url link when i am paste in textbox cursor not move automatically to the second textbox. and when paste the second textbox the cursor move the not third textbox. please help me how can move automatically cursor textbox only past. not mixmim leg using. only using paste. send completely code java script and input code quickly thanks Hello guys, im working on another little project for my team here, and the way our system works is in order to change a persons password, there is a certain link that has to be accessed...for example...if i want to change a persons password, lets say UserID: t-test100 current pass: 911 and i want to change the password to 999 instead of 911...there is a link that needs to sorta load the profile in the background first in order to do the password change, i got the password change page down to a T and it works like a charm, but ONLY when the link is accessed, so for example, this is how the link would look like https://www.***.com/Sps/jsp/MyChange...?uid=t-test100 as soon as that URL is accessed, my code that i made for the password reset, works, but if i open a fresh window (where no cookies have been logged) and i go directly to my page where i have the script to change the password, it will come back with an error, but when i go to that URL and then back to my script and run it again, it works fine....SOOOO...back to my question...how would i be able to make it so that i have an extra link on my site that i can add to go to https://www.***.com/Sps/jsp/MyChange...?uid=t-test100 URL in a new window...but i want it so that when i click the link, it opens up the URL and closes the window after 1 second...or less...just so that it loads the URL in the background and thats it basically what i need to do, just for it to open for a split second, for the browser to register that i've visited the URL for that particular username, and then so that when i try to change the password, it goes through. Hello, I'm working on a somewhat interactive script that uses dynamic content and I'm quite new to javascript so I was wondering how I could download contents from a source such as a file that would give plain text output, display the output and then the client would wait for X seconds before refreshing the content(Discarding the old content)?
Hello to all, new to this forum so pardon any mistakes in my question. I have an overlay that contains a video which loads upon page load. Code: <script type="text/javascript"> $(function() { $("#intro_video").overlay({ mask: { color: '#000', loadSpeed: 1000, startOpacity: 0, zIndex: 9997, opacity: .85 }, top: 131, closeOnClick: true, load: true, onLoad: function(){ var $overlay = this; setTimeout(function(){$overlay.close()}, 44000) }}); }); </script> I'd like to delay this by about 5 seconds or so but can't figure out how to do so as I am a JS n00b. The overlay is contained in a div: <div id="intro_video"> Thank you for your help. I frequent a site that involves typing huge numbers. And I'm thinking of making a userscript that automatically adds commas as I type numbers on all the input boxes. There are multiple input boxes and it has two types: First input type has similar name ; Second input type has similar class. Here's an example of a page: Code: <input type="text" value="0" name="buy_price"><br/> <input type="text" value="0" name="buy_price"><br/> <input type="text" value="0" name="buy_price"><br/> <br/> <input type="text" value="0" class="money-input"><br/> <input type="text" value="0" class="money-input"><br/> <input type="text" value="0" class="money-input"> My code so far. But it doesn't seem to work. The main function was taken from here. Code: function add_commas(number){ //remove any existing commas... number=number.replace(/,/g, ""); //start putting in new commas... number = '' + number; if (number.length > 3) { var mod = number.length % 3; var output = (mod > 0 ? (number.substring(0,mod)) : ''); for (i=0 ; i < Math.floor(number.length / 3); i++) { if ((mod == 0) && (i == 0)) output += number.substring(mod+ 3 * i, mod + 3 * i + 3); else output+= ',' + number.substring(mod + 3 * i, mod + 3 * i + 3); } return (output); } else return number; } function addattribute() { //adds onkeyup and removes zero of first input type document.getElementsByName("buy_price")[0].setAttribute("onkeyup", "this.value=add_commas(this.value);"); document.getElementsByName("buy_price")[0].removeAttribute('value'); //adds onkeyup and removes zero of second input type document.getElementsByClassName("money-input")[0].setAttribute("onkeyup", "this.value=add_commas(this.value);"); document.getElementsByClassName("money-input")[0].removeAttribute('value'); } window.onload = addattribute; EDIT: I believe the function function add_commas(number) works. But the problem is I need to find a way to add onkeyup="this.value=add_commas(this.value);" to the input boxes mentioned. EDIT #2: Well I guess I'm back to 0.The function function add_commas(number) seems to only work if it's on the actual html file inside <script> tags. But once you separate it and apply it as a userscript, it doesn't seem to function. is there a HTML or a java script code that will allow me to create a link on my page and this link will allow me to access a site (that requires my username and password) to be automatically logs me in and access the data. or is there a way to enter the username and password to the URL that would help me not to login... So far what I have the animation just..repeats over and over again, it doesn't go forward and backward as a seem-less bouncing little pin. Rattling my brain here, any help? I uploaded it to my server he http://www.boomspeed.com/alenna06/BouncingPushPin.html Also zip file attached Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Pin bouncing</title> <meta http-equiv="content-type" content="text/html;charset=iso-8859-1" /> <script type="text/javascript"> /* <![CDATA[ */ var pins = new Array(9); var curPins= 0; var direction; var begin; for (var i = 0; i < 9; ++i){ pins[i]=new Image(); pins[i].src="pin" + i + ".gif"; if (i == 8) begin = setInterval("bounce()", 90); function bounce() { if (curPins == 8){ curPins = 0; } else ++ curPins; document.getElementsByTagName("img")[0].src = pins[curPins].src; if(curPins == 0){ direction = "up"; } else if (curPins == 8) direction ="down"; document.getElementsByTagName("img")[0].src= pins[curPins].src; } } /* ]]> */ </script> </head> <body> <img src="pin0.gif" alt="Image of push pin bouncing" /> </body> </html> |