JavaScript - Javascript Alignment
Hello everyone,
I am new to CSS and am having some difficulties with javascript alignment. I have inserted the proper script into my banner and it is in the proper spot but its too far left. I would like to be able to move it into the center. What should I be adjusting? Not really sure how padding etc all works and not sure if that's how i would go about fixing it. Thanks Similar TutorialsHey just a quick question... I have something centered on my page (its a table). How can I align something to the left of what I already have centered?
I've having a problem with alignment on my portfolio. It works in mozilla although you may need to refresh the page, and it doesn't work in chrome at all. does anyone know why? the address is townsendwebdd.com thanks, I am totaly stuck I wasn't sure whether this needed to go in Javascript or in CSS. In the code I have below, I have a popup box that's displayed via javascript. It is supposed to be displayed in the center of the screen no matter what the location of the link is when it is clicked. All the JS part works fine, I believe the issue is in the HTML/CSS itself, but I'm not sure. As it is now, it works fine on IE, and everything is aligned properly, but it is offset to the right (by roughly 150px or so, I think) in Firefox. However, if I uncomment the line that is commented out (which would define the "right" attribute" of #outside and #behindoutside, instead of leaving it to default), the problem is reversed. Does this have something to do with a difference in FF/IE's handling of the "position" attribute in CSS? That has been my best guess so far but I still haven't been able to fix the error. Also, the box does not appear to fade in/out at all in IE. This is less of a concern to me than the alignment, but still somewhat of a problem. EDIT: I've come up with a (hopefully temporary) solution of using an if statement to determine if the browser is Firefox, but I would prefer to fix the actual source issue instead of just fixing the problem is causes.so Code: <html> <head> <meta http-equiv="content-type" content="text/html;charset=iso-8859-1"> <meta name="generator" content="Adobe GoLive"> <title>Untitled Page</title> <script type="text/javascript" src="http://207.200.19.180/images/10000/6000/170BE/user/jquery-1.3.2.js" /></script> <style type="text/css"> #behindoutside{ opacity:0.90 !important; text-align: center; position: absolute; width: 100% !important; z-index: 0; } #x{ filter:alpha(opacity=90) !important; opacity:0.90 !important; } #image{ filter:alpha(opacity=90) !important; background-color: silver; border: 1px solid black; width: 100%; height: 100%; } #insidebehindoutside{ height: 420px; width: 550px; } #outside{ width: 100%; text-align: center; position: absolute; z-index: 1; } #popup{ text-align: center; height: 420px; width: 550px; } </style> <script language="javascript"> $(document).ready(function(){ $('#start').click(function(){ $("#outside, #behindoutside").fadeIn('normal'); var boxheight = $("#insidebehindoutside").height(); var tall = jQuery(window).height(); var scroll = jQuery(window).scrollTop(); var heightShift=((tall/ 2 ) - (boxheight / 2 )) + scroll; $("#outside, #behindoutside").css("top", heightShift); //$("#outside, #behindoutside").css("right", "2px"); }); $('#x').click(function(){ $('#outside, #behindoutside').fadeOut('normal'); }); }); </script> </head> <body> <div id="behindoutside" style="display:none;"> <center> <div id="insidebehindoutside"> <img id="image" src="http://207.200.19.180/images/10000/3000/914BE/user/blank.png"/> </div> </center> </div> <div id="outside" style="display:none;"> <center> <div id="popup"> <img id="x" style="float:right; position: relative; right: 5px; top:5px; cursor:pointer;" onmousedown="getElementById('x').src='http://207.200.19.180/images/10000/6000/170BE/user/xdown.gif'" onmouseup="getElementById('x').src='http://207.200.19.180/images/10000/6000/170BE/user/xup.gif';" onmouseout="getElementById('x').src='http://207.200.19.180/images/10000/6000/170BE/user/xup.gif'" src="http://207.200.19.180/images/10000/6000/170BE/user/xup.gif" /> <br><br> <p>Popup Content</p></div> </center> </div> <div> <center> <font size="3">Supply Lists</font> <hr align="center" width="25%" /> </center> <p align="center"><a id="start" style="color: blue; text-decoration: underline; cursor:pointer;" onclick="appear();">Click for popup box!</a></p> </div> </body> </html> Hello, I'm using the jk mega menu found at: http://www.javascriptkit.com/script/...megamenu.shtml My menu is about 600px wide. When I resize the browser window smaller, the menu seems to auto adjust to the new window size and aligns the menu bottom/ extending left of the anchor, as opposed to the default (bottom/extending right.) I'd like to force the menu always extending right because extending left is sending it off the page left. Collapse this window smaller and roll over the menu and you'll see the issue: http://www.javascriptkit.com/script/...megamenu.shtml Thanks for any help you can provide and I appreciate your time, I would like to change the alignment of an image which currently under div which is under iframe. the page which is called under iframe is readymade html from some other site. I dont have any control on that HTML page which is under iframe. Please tell me how to align image under iframe.
I want to have another go at Javascript. I have several books on the subject but I find that my eyesight is a major problem. Therefore I want to try an on-line solution, preferably free. I have Googled, but there are so many that I am almost dizzy with the choices. Perhaps someone could recommend one. Not too fussy visually. My knowledge is VERY basic. Frank Hello! I am trying to find a script that allows you to open multiple browser tabs and then close each of those tabs, either one by one or all at once. Does anyone know how to do this please? Thanks so much for your help. Does anyone know how to make URL links that use Javascript still work when users have Javascript disabled on their browser? The only reason I'm using JS on a URL is because my link opens a PDF file, and I'm forcing it not to cache so users have the latest version. I tried the <script><noscript> tags, but I'm not sure if I'm using it correctly, as my URL completely disappears. Below is my HTML/Javascript code: <p class="download"> <script type="text/javascript">document.write("<span style=\"text-decoration: underline;\"><a href=\"javascript:void(0);\" onclick=\"window.open( 'http://www.webchild.com.au/mediakit/Direct_Media_Kit_Web.pdf?nocache='+ Math.floor( Math.random()*11 ) );\" >The Child Magazines Media Kit</a></span> (PDF 1 MB) ");</script> <noscript><span style="text-decoration: underline;"><a href="http://www.webchild.com.au/mediakit/Direct_Media_Kit_Web.pdf" >The Child Magazines Media Kit</a></span> (PDF 1 MB)</noscript> </p> Thanks for any help, Michael Hi, I have the following code snippet: test.html ====== <script language="javascript" type="text/javascript"> var testVariable = "test"; </script> <script language="javascript" type="text/javascript" src="test.js"> </script> test.js ===== var testVariable = window.top.testVariable; In firefox, I'm able to access testvariable defined within test.html in test.js. But in chrome, test.js couldnot get the window.top.testVariable field defined in test.html. Can any one please let me know how i can make it work in chrome?. Am i missing something here?. Hi Guys, I am new at JavaScript and start to do some tutorials.What I am trying to do here is prompting user to input a name and if the name was valid the page(document) will display with all objects like the button.But if user enter a wrong name then the button will be disabled! I create the following code but it did not work <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>New Web Project</title> <script language="JavaScript" type=""> function changeColor(){ document.bgColor = "Gray"; } </script> </head> <body> <script language="JavaScript" type="text/javascript"> var person = ""; person = prompt('What is Your Name:'); if (person == "Foo") { document.write("<h1 />Welcome " + person); document.bgColor = "Yellow"; } else { document.write("<h1 />Access Denied!!!!"); document.bgColor = "Red"; document.getElementById("gree").disabled = true; } </script> <div> <p/><input id="gree" type="button" value="Gray " onClick="changeColor();"> </div> </body> </html> as you can see I used the: document.getElementById("gree").disabled = true; but it did not work , could you please give an idea how I can solve this problem? Thanks Hey, I've got to make the values of some textboxes change the co-ordinates of my sprite on a canvas and havent a clue on how to do it, Here is my form with the two textboxes and submit button: <form> x: <input type="text" name="x" /><br /> y: <input type="text" name:"y" /><br /> <input type="submit" value="Submit"/><br /> </form> And i need it so that they change the values of these: //this shows where my sprite will start on the canvas var block_x; var block_y; searched the internet for hours and cant really find anything i understand or works. any help is much appreciated I got an index.php Code: <html> <form action="bacakomik.php" method='post'> <select name="kodekomik"> <option value='../komik1/|23'>Judul Komik1</option> <option value="../komik2/|20">Judul Komik2</option> <option value="../komik3/|10">Juduk Komik3</option> <option value="../komik4/|20">Judul Komik4</option> </select> <input type="submit" /> </form> <?php echo ('<select>'); echo ('<option value= "'.$i.'">'.'Page '.$i.'</option>'); echo ('</select>'); ?> </html> As you can see, each of the option brings specific value "../komik1/|23" komik1 is a directory | is a delimiter 23 is the pages in one chapter and can be considered also as how many images are there on a specific directory This is my bacakomik.php Code: <?php $dirkomik = $_POST['kodekomik']; $exploded = explode("|", $dirkomik); echo ($exploded[0]); //picture directory echo ("<br>"); echo ($exploded[1]); //total page in the comic $pagecount = (int)$exploded[1]; //Take last posted value, process it right away echo ('<FORM name="guideform"> '); echo ('<select name="guidelinks">'); $i=1; do { echo ('<option value= "'.$i.'">'.'Page '.$i.'</option>'); $i= $i+1; }while($i <= $pagecount); //Printing option and select echo ("</select>"); ?> <input type="button" name="go" value="Go!" onClick="document.getElementById('im').src=document.guideform.guidelinks.options[document.guideform.guidelinks.selectedIndex].value+'.png';"> </FORM> <img src="img0.jpg" id="im"> With the current code on bacakomik.php, I only can change the img src of id "im" in the same directory only. What I want is that the Javascript could "add" the "$exploded[0]" variable so that the picture can be loaded from different directory. Anyone can do this? I believe that the fix should be somewhere on input tag inside OnClick, or do you know where? Anyway, I found this on the net http://p2p.wrox.com/php-faqs/11606-q...avascript.html Please help me to those who can... Hi Guys I am trying to modify the functionality of my page. I want to be able to activate this piece of code using another javascript function. This is the code I want to activate: Code: <script type="text/javascript"><!-- $('#button-cart').bind('click', function() { $.ajax({ url: 'index.php?route=checkout/cart/update', type: 'post', data: $('.product-info input[type=\'text\'], .product-info input[type=\'hidden\'], .product-info input[type=\'radio\']:checked, .product-info input[type=\'checkbox\']:checked, .product-info select, .product-info textarea, .date_data input[type=\'text\']'), dataType: 'json', success: function(json) { $('.success, .warning, .attention, information, .error').remove(); if (json['error']) { if (json['error']['warning']) { $('#notification').html('<div class="warning" style="display: none;">' + json['error']['warning'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>'); $('.warning').fadeIn('slow'); } for (i in json['error']) { $('#option-' + i).after('<span class="error">' + json['error'][i] + '</span>'); } } if (json['success']) { $('#notification').html('<div class="success" style="display: none;">' + json['success'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>'); $('.success').fadeIn('slow'); $('#cart_total').html(json['total']); $('html, body').animate({ scrollTop: 0 }, 'slow'); } } }); }); //--></script> And this is how I want the format of the function to be: function testsession() { if there is a session called 'hiredate' { activate the script above } else { var el = document.getElementById("product_data"); } } I just dont know how to write this in javascript Could you help me if possible please I want to insert this js snippet Code: function addText(smiley) { document.getElementById('message').value += " " + smiley + " "; document.getElementById('message').focus(); return false; } to a loaded iframe with name&id chtifrm. I can access it & change embed something in its html via using something like: Code: $(parent.chtifrm.document.body).append('<div id=\"smly\" style=\"cursor:pointer;float:left;top:200px;display:none;position:absolute;\"><\/div>'); .... Code: parent.chtifrm.document.getElementById('chatbox_option_disco').style.display == 'none' but how do I insert js in the head of loaded iframe? All -- I have a JavaScript config file called gameSetting.js which contains a bunch of variables which configures a particular game. I also have a shared JavaScript library which uses the variables in gameSetting.js, which I include like so: <script type="text/javascript" src="gameSetting.js" ></script> <script type="text/javascript" src="gameLibrary.js" ></script> In gameSetting.js I have: $(document).ready(function() { // call some functions / classes in gameLibrary.js } in Firefox, Safari, and Chrome, this works fine. However, in IE, when it's parsing gameSetting.js, it complains that the functions that live in gameLibrary.js aren't defined. When it gets to parsing gameLibrary.js, the variables in gameSetting.js are reported as not being defined. I've tried dynamically bootstrapping the gameLibrary file using this function in document.ready for dynamic load... $.getScript("gameLibrary.js"); However, the same problem still happens in IE, where when it parses the files individually it's not taking into context the file/variables that came before, so it's not an out of load order problem. My options a 1) collapsing all the functions in gameLibrary.js and variables in gameSetting.js into one file. However, this is not practical because this is dealing with literally hundreds of games, and having a gameLibrary.js in ONE location for ONE update is what makes most logical sense. 2) figure out a way to get this to work where variables in file1 are accessible to file2 in IE (as it seems they are in other browsers). jQuery seems to be able to have multiple plugins that all refer to the based jQuery-1.3.2.js, so I know there is a way to get this to work. Help appreciated. Nero I wrote a log function that took note of various function calls. Thinking that functions are first class objects, and objects have properties, I made the name of each logged function a property of that function, e.g., brightenInnerPara.name = "brightenInnerPara"; Every browser I tried (Firefox, MSIE, Opera, Chrome, Safari) accepted the assignment, no problem. In Firefox and MSIE, the result was what I wanted: brightenInnerPara.name == "brightenInnerPara" But in the others, the result was: brightenInnerPara.name == null Question 1. Which Javascript is correct here? I favor Firefox and MSIE, not merely because they were willing to give me what I wanted, but also because it makes no sense to accept an assignment statement without throwing an error and then give it a null semantics, like Chrome, Opera, and Safari did. I found a workaround, using assignments like this: brightenInnerPara.prototype.name = "brightenInnerPara"; To my surprise, that worked in every browser. But I don't know why. It seems that such assignments are enough to cause each function to have its own distinct prototype. Question 2. Just how inefficient is my workaround, and why does it work? hello wj friends please help in javascript. i figured out all problem and got solution but one i can't figure out please help me the problem is see this link http://www.sajeebgroup.com in this page see right side update news box. a slider is sliding but before one slider another slide is coming why this. here is slide javascript code PHP Code: (function($) { $.fn.easySlider = function(options){ // default configuration properties var defaults = { prevId: 'prevBtn', prevText: 'Previous', nextId: 'nextBtn', nextText: 'Next', controlsShow: true, controlsBefore: '', controlsAfter: '', controlsFade: true, firstId: 'firstBtn', firstText: 'First', firstShow: false, lastId: 'lastBtn', lastText: 'Last', lastShow: false, vertical: false, speed: 800, auto: false, pause: 2000, continuous: false, numeric: false, numericId: 'controls' }; var options = $.extend(defaults, options); this.each(function() { var obj = $(this); var s = $("li", obj).length; var w = $("li", obj).width(); var h = $("li", obj).height(); var clickable = true; obj.width(w); obj.height(h); obj.css("overflow","hidden"); var ts = s-1; var t = 0; $("ul", obj).css('width',s*w); if(options.continuous){ $("ul", obj).prepend($("ul li:last-child", obj).clone().css("margin-left","-"+ w +"px")); $("ul", obj).append($("ul li:nth-child(2)", obj).clone()); $("ul", obj).css('width',(s+1)*w); }; if(!options.vertical) $("li", obj).css('float','left'); if(options.controlsShow){ var html = options.controlsBefore; if(options.numeric){ html += '<ol id="'+ options.numericId +'"></ol>'; } else { if(options.firstShow) html += '<span id="'+ options.firstId +'"><a href=\"javascript:void(0);\">'+ options.firstText +'</a></span>'; html += ' <span id="'+ options.prevId +'"><a href=\"javascript:void(0);\">'+ options.prevText +'</a></span>'; html += ' <span id="'+ options.nextId +'"><a href=\"javascript:void(0);\">'+ options.nextText +'</a></span>'; if(options.lastShow) html += ' <span id="'+ options.lastId +'"><a href=\"javascript:void(0);\">'+ options.lastText +'</a></span>'; }; html += options.controlsAfter; $(obj).after(html); }; if(options.numeric){ for(var i=0;i<s;i++){ $(document.createElement("li")) .attr('id',options.numericId + (i+1)) .html('<a rel='+ i +' href=\"javascript:void(0);\">'+ (i+1) +'</a>') .appendTo($("#"+ options.numericId)) .click(function(){ animate($("a",$(this)).attr('rel'),true); }); }; } else { $("a","#"+options.nextId).click(function(){ animate("next",true); }); $("a","#"+options.prevId).click(function(){ animate("prev",true); }); $("a","#"+options.firstId).click(function(){ animate("first",true); }); $("a","#"+options.lastId).click(function(){ animate("last",true); }); }; function setCurrent(i){ i = parseInt(i)+1; $("li", "#" + options.numericId).removeClass("current"); $("li#" + options.numericId + i).addClass("current"); }; function adjust(){ if(t>ts) t=0; if(t<0) t=ts; if(!options.vertical) { $("ul",obj).css("margin-left",(t*w*-1)); } else { $("ul",obj).css("margin-left",(t*h*-1)); } clickable = true; if(options.numeric) setCurrent(t); }; function animate(dir,clicked){ if (clickable){ clickable = false; var ot = t; switch(dir){ case "next": t = (ot>=ts) ? (options.continuous ? t+1 : ts) : t+1; break; case "prev": t = (t<=0) ? (options.continuous ? t-1 : 0) : t-1; break; case "first": t = 0; break; case "last": t = ts; break; default: t = dir; break; }; var diff = Math.abs(ot-t); var speed = diff*options.speed; if(!options.vertical) { p = (t*w*-1); $("ul",obj).animate( { marginLeft: p }, { queue:false, duration:speed, complete:adjust } ); } else { p = (t*h*-1); $("ul",obj).animate( { marginTop: p }, { queue:false, duration:speed, complete:adjust } ); }; if(!options.continuous && options.controlsFade){ if(t==ts){ $("a","#"+options.nextId).hide(); $("a","#"+options.lastId).hide(); } else { $("a","#"+options.nextId).show(); $("a","#"+options.lastId).show(); }; if(t==0){ $("a","#"+options.prevId).hide(); $("a","#"+options.firstId).hide(); } else { $("a","#"+options.prevId).show(); $("a","#"+options.firstId).show(); }; }; if(clicked) clearTimeout(timeout); if(options.auto && dir=="next" && !clicked){; timeout = setTimeout(function(){ animate("next",false); },diff*options.speed+options.pause); }; }; }; // init var timeout; if(options.auto){; timeout = setTimeout(function(){ animate("next",false); },options.pause); }; if(options.numeric) setCurrent(0); if(!options.continuous && options.controlsFade){ $("a","#"+options.prevId).hide(); $("a","#"+options.firstId).hide(); }; }); }; })(jQuery); here is php to show slide PHP Code: <html. <head> <style type="text/css"> #ticker-container { position:relative; /*overflow:hidden;*/ width: 190px; height: 200px; padding-top:0px; color:#000000; margin-top:0px; margin-bottom:1px; } #ticker { position:relative; overflow:hidden; margin-left:50px; margin-right:20px; margin-top:25px; width:155px; padding:0px; } </style> <!-- SLIDER START --> <script type="text/javascript" src="robin/easyslider/js/jquery.js"></script> <script type="text/javascript" src="robin/easyslider/js/easySlider.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#ticker").easySlider({ auto: true, continuous: true }); }); </script> <link href="robin/easyslider/css/screen.css" rel="stylesheet" type="text/css" media="screen" /> </script> </head> <body> <div id="ticker-container"> <div id="ticker"> <ul> <?php include("robin/notice/config.php"); $query = "SELECT id, title,body,name FROM notice"; $result = mysql_query($query); $num = mysql_num_rows($result); while ($row = mysql_fetch_assoc($result)) { $name = $row['name']; echo '<li><a href="robin/notice/fullarticle.php?id='.$row["id"].'" rel="popup standard 700 600 noicon"><img src="kcfinder/upload/.thumbs/images/'.$name.'" width="150px" height="150px" /></a></li>'; } ?> </ul> </div> </div> </body> </html> please help Hi guy's Not sure if what i want to do is possible, i am a very basic computer user and any help would be great. i have a relay that is conect to my router and if i type the following into the address bar it turns it on for 2 seconds. "http://192.168.1.68/state.xml?relayState=2" What i would love to do is be able to add a book mark which once selected it fires off the above string and closes the window without a prompt, is this possible??? i have spent hours and hours and seem to be going nowhere. Thanks for all your help Daniel This is a basic question, in the code below if I inputed 2 how can I echo the word hello? Code: <HTML> <HEAD> <TITLE>Test Input</TITLE> <SCRIPT LANGUAGE="JavaScript"> function testResults (form) { var TestVar = form.inputbox.value; if(TestVar!=2) { document.write("please enter 2"); } } </SCRIPT> </HEAD> <BODY> <FORM NAME="myform" ACTION="val4.php" METHOD="post">Enter something in the box: <BR> <INPUT TYPE="text" NAME="inputbox" VALUE=""><P> <INPUT TYPE="submit" NAME="button" Value="Click" onClick="testResults(this.form)"> </FORM> <?php if (isset($_POST['button'])) { echo "hello you inputed the right value"; } ?> </BODY> </HTML> |