JavaScript - Trying To Remove Spacing Around Script
I'm working on a webpage where I used this code to display random images. I used it for three images in a row and I keep getting white spacing in between them when they should be right up against each other. This is the code I'm using:
Code: <script language="JavaScript"> <!-- /* Random Image Script- By JavaScript Kit (http://www.javascriptkit.com) Over 400+ free JavaScripts here! Keep this notice intact please */ function random_imglink(){ var myimagesblue=new Array() //specify random images below. You can have as many as you wish myimagesblue[1]="images/circles_blue/circle_bl_01.jpg" myimagesblue[2]="images/circles_blue/circle_bl_02.jpg" myimagesblue[3]="images/circles_blue/circle_bl_03.jpg" myimagesblue[4]="images/circles_blue/circle_bl_04.jpg" myimagesblue[5]="images/circles_blue/circle_bl_05.jpg" myimagesblue[6]="images/circles_blue/circle_bl_06.jpg" myimagesblue[7]="images/circles_blue/circle_bl_07.jpg" myimagesblue[8]="images/circles_blue/circle_bl_08.jpg" myimagesblue[9]="images/circles_blue/circle_bl_09.jpg" myimagesblue[10]="images/circles_blue/circle_bl_10.jpg" myimagesblue[11]="images/circles_blue/circle_bl_11.jpg" var ry=Math.floor(Math.random()*myimagesblue.length) if (ry==0) ry=1 document.write('<img src="'+myimagesblue[ry]+'" border=0>') } random_imglink() //--> </script> Is there a way to get the white space removed? Thanks Similar TutorialsHopefully this is a noob and simple question to answer, but I used this random ads script and modified it to show random boxarts for PS3 games.. http://javascript.internet.com/misce...andom-ads.html You can see what I'm trying to do he http://empireelite.org/index2.htm - (temporary page just for testing the code, refresh and see that the PS3 boxarts become randomized) Everything looks perfect in Internet Explorer, but in Firefox it looks to have about 15px in spacing on both top and bottom. I know the table itself is fine, because everything fits fine on the real main page http://www.empireelite.org/ The pictures are also not overlapping the cell. It's 9 pics x 22 width, (198px in a 200px wide cell) and it has the same spacing even if I just have 1 pic there using the script. Is there a code I can add or remove to get rid of the spacing in Firefox? I already removed , spacing from this line: function randomorder(targetarray, spacing) { and removed +spacing from this line: document.write(targetarray[the_one]+spacing) Neither did anything and the script works the same way without those small pieces of code (I'm not sure what either of them did to begin with). Here is the javascript page I'm using: http://empireelite.org/randomAds.js And also View Source in this test page: http://empireelite.org/index2.htm Hi, I have a regular expression which removes anything between <script> and </script> tags. The problem comes when there is more than one on a page, eg. Code: <script>lose this</script> content I want to keep <script>lose this</script> Everything in that string is removed... how can I limit it to complete tags only? I did a search but could only find ones that either remove tags only, or have the same problem as mine. Cheers, Gus I have a check box right now that calls an onClick event. Here is the Input: Code: <input name="usePad" type="checkbox" value="usePad" id="usePad" onclick="showBind('padShow','padOk')" /> Here is the Script: Code: var xmlhttpshowBind; var showBindDiv; function showBind(BindPage,BindDiv) { xmlhttpshowBind=GetXmlHttpObject(); if (xmlhttpshowBind==null) { alert ("Browser does not support HTTP Request"); return; } var url="/scripts/"+BindPage+".php"; showBindDiv=BindDiv; xmlhttpshowBind.onreadystatechange=showBindGet; xmlhttpshowBind.open("GET",url,true); xmlhttpshowBind.send(null); } function showBindGet() { if (xmlhttpshowBind.readyState==4) { document.getElementById(showBindDiv).innerHTML=xmlhttpshowBind.responseText; } } It works great to fill the div called for, but I would like it to remove the div contents if it's unchecked, I'm not sure how to do this?? Any help would be appreciated! Thank you in advance! Hello, I am new to Javascript. I copied this script from the web, but I get an error at this line: parent.removeChild(child); The error says "Invalid argument". Any suggestions are greatly appreciated. Code: <div id="parent" align=center> <form name=mainfrm method=post> <script language="JavaScript"> function doDelete(str1,str2) { var parent = document.getElementById(str1); var child = document.getElementById(str2); parent.removeChild(child); alert ("box removed"); } </script> <br><br> <table> <td class=stdbut1 onmouseover="this.className='stdbut1on'" onClick="doDelete('parent','child');" onmouseout="this.className='stdbut1'">Delete Box</td> </table> <br><br> <div id="child" class=titlebox1>Box</div> </form> </div> Hi, I got this two javascripts: - Datepicker by Jason Moon (http://calendar.moonscript.com/dateinput.cfm) which can have multiple of this datepicker on a single form - Dynamic Add/Remove rows from http://viralpatel.net/blogs/2009/03/...avascript.html I would like to add rows of fields with each rows having it's individual datepicker. Code: <table id="billcmp_7" width="320" border="0"> <tr> <td width="200" align="center"><script>DateInput('billcmp7_cycle', true)</script></td> <td width="10"> </td> <td width="100" align="center"><input name="billcmp7_name" type="text" /></td> <td width="10"><INPUT type="checkbox" name="chk"/></td> </tr> </table> <table width="320" border="0"> <tr> <td colspan="4" align="center"><INPUT type="button" value="Add Row" onclick="addRow('billcmp_7')" /><INPUT type="button" value="Delete Row" onclick="deleteRow('billcmp_7')" /></td> </tr> </table> I just want this section Code: <script>DateInput('billcmp7_cycle', true)</script> to work like Code: <script>DateInput('billcmp7_cycle_1', false)</script> <script>DateInput('billcmp7_cycle_2', false)</script> when click on the add button. Here's what i meant? Link cant get the time to be different as it is still read as single datepicker. Any1 has any idea how or any alternative? Hello everyone, I'm having trouble getting some spacing in my code. Here's my function below. Code: function buildResume() { resName = document.myResume.name.value resAddress = document.myResume.address.value resPhone = document.myResume.phone.value resEmail = document.myResume.email.value resInfo = document.myResume.info.value flyWindow = window.open() flyWindow.document.write(resName + "<br>" + resAddress + " / " + resPhone + "<br>" + resEmail + "<br>" + "<hr width=36% align=left>") flyWindow.document.write("Personal Information" + resInfo) } The part I'm trying to add spacing between this part. Code: flyWindow.document.write("Personal Information" + resInfo) It comes out as: Personal Information *whatever the value of resInfo is* I would like it so it reads as (underscores being the spaces): Personal Information________*whatever the value of resInfo is* I've tried using   but could not get it to work, maybe I'm using it wrong. If anyone could shed some light on this for me it'd really help. If you need to see some more of my code let me know too. Hi there, My last 2 little annoyances are related to my Cufon main menu. I could use some assistance. http://www.lyricoperala.org/index3.html Sub-menu items are spaced too far apart. I've tried to set the top padding to 0px, but that doesn't seem to have made a difference. Finally, the last item is a CSS issue, but I'll mention it here just in case you, my code savior, happen to know the answer. I guess it's a z-index thing, but I haven't mastered this yet. My sub-sub-menu items are appearing UNDER the ticket image. I'd prefer that they show up above it, obviously. Thanks so much in advance! Best forum helpers EVER here! ~Laura Hello, I'm currently using this code: I want it so that there isnt a box around the countdown, and the countdown is the same text as "you will be redirected in" here is it in action: http://www.playelite.org/redirect.html Code: <form name="redirect"> <center> <font face="Arial"><b>You will be redirected in: <form> <input type="text" size="3" border="0" name="redirect2"> </form> seconds</b></font> </center> <script> <!-- var targetURL="http://google.com" var countdownfrom=10 var currentsecond=document.redirect.redirect2.value=countdownfrom+1 function countredirect(){ if (currentsecond!=1){ currentsecond-=1 document.redirect.redirect2.value=currentsecond } else{ window.location=targetURL return } setTimeout("countredirect()",1000) } countredirect() //--> </script> Thanks Hi all, here i got a problem, i want to remove all the Li tag that with a classname"test" . Code: <html> <head> <title>Introduction to the DOM</title> <script> window.onload = function(){ var li = document.getElementsByTagName("li"); for ( var j = 0; j < li.length; j++ ) { if(li[j].getAttribute('class')=='test'){ li[j].parentNode.removeChild( li[j] ); } } }; </script> </head> <body> <h1>Introduction to the DOM</h1> <p class="test">There are a number of reasons why the DOM is awesome, here are some:</p> <ul> <li class="ppp">ppp.</li> <li class="test">It's easy to use.</li> <li class="test">It can help you to find what you want, really quickly.</li> <li class="test">It's easy to use.</li> <li class="test">It can help you to find what you want, really quickly.</li> <li class="test">It's easy to use.</li> <li class="test">It can help you to find what you want, really quickly.</li> <li class="test">It's easy to use.</li> <li class="test">It can help you to find what you want, really quickly.</li> <li class="test">It's easy to use.</li> <li class="test">It can help you to find what you want, really quickly.</li> <li class="test">It's easy to use.</li> <li class="test">It can help you to find what you want, really quickly.</li> <li class="test">It's easy to use.</li> <li class="test">It can help you to find what you want, really quickly.</li> <li class="test">It's easy to use.</li> <li class="test">It can help you to find what you want, really quickly.</li> </ul> </body> </html> I'm using jQuerys' $.ajax to load a div with some details in it and i want to use the esc key to close the div. Heres the code so far Code: $('.username span').click(function(){ $('.MiniPro').remove(); ID = $(this).parent().attr('ID'); This = $(this).parent(); miniPro(); }); function miniPro() { $(This).append('<div class="MiniPro">Loading...</div>'); $.ajax({ type: 'POST', data: 'userID='+ID, url: 'processing/miniPro.php', success: function(msg) { $('.MiniPro').remove(); $(This).append('<div class="MiniPro"'+msg+'<div class="MiniProClose">X</div></div>'); } }); } Is it even possible to do that? I am using this script that gets messed up when you resize the window. I figured out that I could use this other script to do stuff just after the window gets resized. Code: (function($,sr){ // debouncing function from John Hann // http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/ var debounce = function (func, threshold, execAsap) { var timeout; return function debounced () { var obj = this, args = arguments; function delayed () { if (!execAsap) func.apply(obj, args); timeout = null; }; if (timeout) clearTimeout(timeout); else if (execAsap) func.apply(obj, args); timeout = setTimeout(delayed, threshold || 100); }; } // smartresize jQuery.fn[sr] = function(fn){ return fn ? this.bind('resize', debounce(fn)) : this.trigger(sr); }; })(jQuery,'smartresize'); // usage: $(window).smartresize(function(){ // code that takes it easy... }); So I re-instantiate the misbehaving script in there so it fires whenever the window is resized (I changed it to 500 so it really only fires once after you are done resizing). This fixes it. The new instance doesn't have a problem but the old instance is still there and messed up. so I use. $($.misbehaving-script).remove(); just before instantiating after window resize, which gets rid of broken instance. Problem solved.. Except that messes up a different script! It's driving me crazy. Any advice would of course be very welcome. Hi Guys, I'm new at JS. I need to remove TR elements from parent table but the problem is there are no table ID/Name Is it possible to perform it? Please see attach - i need remove red marked block... what scrip i have to use if i will put it to the green block? Thank you. i am doing an edit operation in my web page by changing a image, but when i am revisiting the page it is showing older image rather than new one. So can any one say how to refresh the page without using any button like window.location.reload(). Is there any way to use math.random in url?? Code: <!-- Add-in device.js files are placed here --> <div id="deviceScript"></div> What I have been doing is clearing this out when I select a new (add-in) device and append a script tag with its .src file. I have some vague idea that unhooking an external js file might remove its code from memory. If not is there a way to do so? Functions in different script files have the same name - for example, I use start() to set up each device. It seems that the latest device start() overwrites the one in memory - but I am not sure if overwrite means delete last one or whether there is some horrendous build up of dross going on. Any clarification appreciated. So say if my string was.. Code: a = "Hello"; alert(a); How do I get it to say; Code: alert("ello"); So how do I take off the 'H' in this example.. Hi I have javascript which calls a load of Java applet functions, there are many of these, and the parameters are all the same. The only thing that changes is the name of the function to call. So here is an example of the Javascript: Code: function answercall() { try { document.frm.response.value = document.Telepop.Answercall(document.telepopfrm.extension.value); } catch(err) { alert(err.description); } } function clearcall() { try { document.telepopfrm.response.value = document.Telepop.Clearcall(document.telepopfrm.extension.value); } catch(err) { alert(err.description); } } function holdcall() { try { document.telepopfrm.response.value = document.Telepop.Holdcall(document.telepopfrm.extension.value); } catch(err) { alert(err.description); } } etc, etc.... and the html like this: <input type="button" value="Answer" onclick="answercall()" /> <input type="button" value="Hangup" onclick="clearcall()" /> <input type="button" value="Hold" onclick="holdcall()" /> There does seem to be a lot of duplication here, so I was wondering of ways to reduce or eliminate the duplication. any ideas? AC Hi, Suppose I have this: Code: <a href="#" class="play" onclick="Audio('lol.mp3')"> As you see, when a user will click on the link, it will play an audio. Good! I want to know if I have another button, let's say <button>Remove</button>, how can I disable the "onClick" event on the link above? And also when clicking on a third button <button>Add</button>again, it will enable the function again to work? NOTE: I do not want an HTML5 audio Stop button. This is different. I just want to know how to enable and disable function event. Thank! I'm trying to set the contact form on http://gspbuzz.com/test to remove the text when a user clicks it. Any idea how I can accomplish this?
Is it possible to convert "xyz123456xyz789" into "123456xyz789"? What I'm trying to say is, remove the first occurence of "xyz" from the string, so that all the other occurrences of "xyz" that aren't the first one, remain. Help is appreciated. Thanks, Jazzo hello i need help in deleting a code part, like: table, ul ... the problem is that when i use rss feeds, lot of them add some code parts that i don't need like: <ul class="similar-topics">, and it shows similar topics so, i want to remove this code part from the rss feed i think that i may add a javascript code to the rss template that brings the rss feeds, so as it remove the part i define i hope you help me doing this, even with another idea another idea is to use: http://pipes.yahoo.com i"m sure there is a way to cut parts from the code, but i couldn't get it yet and i'm still trying Regards |