JavaScript - Resize Div's Onload
Hi,
I got some JavaScript code from the net to resize DIV's depending on the window-size. It works perfectly in FF, but it won't work in IE. Code: function Resize(){ var winW = 630, winH = 460; if (parseInt(navigator.appVersion)>3) { if (navigator.appName=="Netscape") { winW = window.innerWidth-30; winH = window.innerHeight-200; } if (navigator.appName.indexOf("Microsoft")!=-1) { winW = document.body.offsetWidth-30; winH = document.body.offsetHeight-200; } } var topHeight = document.getElementById('top').offsetHeight; var setHeight = document.getElementById('settings').offsetHeight; var headersHeight = document.getElementById('headers').offsetHeight; var leftWidth = document.getElementById('left_column').offsetWidth; document.getElementById('container').style.width=winW+"px"; document.getElementById('container').style.height=(winH-topHeight-setHeight)+"px"; document.getElementById('headers').style.width=(winW-leftWidth)+"px"; document.getElementById('data').style.width=(winW-leftWidth)+"px"; document.getElementById('data').style.height=(winH-topHeight-setHeight-headersHeight)+"px"; } I've been working on this for some days. I would appreciate any help I can get. Erik Similar TutorialsHello Can anyone help with the following problem On the following page http://www.stroudskittles.co.uk/signingon.html I have a Body onload event (to load the chained Menu) and a windows.onload event (to load the IFrame Ticker) If I open the page in Internet explorer both scripts function; however in Firefox I'm having problems. The Chained Menu works, however the IFrame Ticker does not display. Both events ahave ben placed on the boady tag. Can anyone advise how I can get both to display in Firefox Can anyone 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? Hi, I'm looking to create a box that shows to IE6 users or lower, to tell them that my site does not render properly in the IE6 browser and that they should therefore upgrade to a newer version or alternative browser. Basically I would put whatever the code to show the box into these tags: Code: <!--[if lte IE 6]> INSERT HERE <![endif]--> to enable it to only appear to IE6 or below users. Preferably when this box appeared, it would be nice if it could fade the page behind it. Does anyone have a script for this or know of a tutorial I could use? The box would also need buttons at the bottom that said "Ok, upgrade me" (this would load another window with links to alternative browsers) or "No thanks" (or "Close") Thanks in advance. I have this code: Code: <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4c7b22470e521876"></script> I want this JavaScript code above to be executed when all My page finished loading (maybe by using JavaScript onload) So how can I do that? Hi all I would like the img src to be populated after page load I'm not sure this is doing what I would like it to do. I have done this. (tag shortened for post) Code: <img src="" id="testImg2" onload="(this.src='images/USA.jpg')"/> Is this populating the img src after page load or when the img tag is loaded? LT Am I saying the onload event wrong or something? PHP Code: <input type="button" value="Mouse" onload="popup_show('popup', 'popup_drag', 'popup_exit', 'mouse', -10, -10);" /> Other events like onmouseover and onClick work hi guys, how can i get this code to load on body onload? without fading in and out? Code: <html> <head> <!-- For ease i'm just using a JQuery version hosted by JQuery- you can download any version and link to it locally --> <script src="http://code.jquery.com/jquery-latest.js"></script> <script> $(document).ready(function() { $("#responsecontainer").load("response.php"); var refreshId = setInterval(function() { $("#responsecontainer").load('response.php?randval='+ Math.random()); }, 9000); $.ajaxSetup({ cache: false }); }); </script> </head> <body> <div id="responsecontainer"> </div> </body> Thanks Hei, On my website , I have certain things that happen in the function window.onload. I need them to happen only the first time when the user acceses the page . Do you have any idea how to do this? Thanks I am using this code Code: <BODY onload="window.top.location='http://localtimes.info/clock.php?cp3_Hex=0F0200&cp2_Hex=FFFFFF&cp1_Hex=000080&fwdt=118&ham=0&hbg=0&hfg=0&sid=&mon=&wek=&wkf=&sep=&continent=Asia&country=Indonesia&city=Jakarta&widget_number=116'"> but the problem is that when the page containing this code loads, it redirects Me to the page (a new page) of the JavaScript code, So how to make this JavaScript code load on the same page and not redirecting Me to a New page? (and make it load when the all page finish loading) rethink
Hi, I'm working on a small bit of code that passes a logged in users email address and name to a live chat form (Zompim & WHMCS) http://api.zopim.com/#setName By striping the code from the above page, I've managed to get it to work when the link is clicked, but I needed to have the variables passed upon page load. If anyone can point me in the right direction that would be great, me and Javascript don't work too well together! Here is what I have so far http://myautodj.com/zomp_test.php (your request a chat, and click on the run script link - that passes the demo email and name) Here is the code Code: <pre><script> $zopim.livechat.set({ language: 'en', name: 'Visitor', email: 'visitor@site.com', onStatus: function(s) { alert(s) } }); </script></pre> <script> (function() { var pres = document.getElementsByTagName('pre'), i; for (i=0; i<pres.length; i++) { buildLiveExample(pres[i]); } function buildLiveExample(p) { var code = p.innerHTML.replace(/>/g, '>').replace(/</g, '<'); var div = document.createElement('div'); if (code.search('<script>') == 0) { var a = document.createElement('a'); a.innerHTML = 'run script'; a.href = '#'; a.onclick = function() { eval(code.replace(/<\/?script>/g, '')); return false; }; div.appendChild(a); } else { div.innerHTML = code.replace(/<script>[\s\S]*?<\/script>/g, '') var code_blocks = code.match(/<script>[\s\S]*?<\/script>/g); if (code_blocks) { for (var i=0; i<code_blocks.length; i++) eval(code_blocks[i].replace(/<\/?script>/g, '')); } } p.parentNode.insertBefore(div, p); } })() </script> <script type="text/javascript"> document.write(unescape("%3Cscript src='" + document.location.protocol + "//zopim.com/?4vXfkefMFbxeWAVPjvRvWnBodfrGzctq' charset='utf-8' type='text/javascript'%3E%3C/script%3E")); </script> Hi Guys, I want to call the below when the page opens as opposed to clicking a link How do I alter it and do i need a function? THANKS <a href="#" onclick="new Lightbox.base('box3', { closeOnOverlayClick : true })">LINK All, I have a function that loads with the onload command. Is there a subsitute for this? I have an AJAX call so sometimes content gets loaded on the page without the onload event being triggered but I need it to go to this function when the AJAX displays the new content. Any ideas? If it makes a difference, the AJAX is calling a PHP page. Thanks in advance. Hi all, I have some javascript that when a link is clicked hides the div and when it is clicked again shows the div... what I want to do is reverse that, so it is intially hidden. I have tried changing the display none to different parts but it always shows on load: Code: function toggleDiv (divid) { if (document.getElementById (divid).style.display == 'none') { document.getElementById (divid).style.display = 'block'; } else { document.getElementById (divid).style.display = 'none'; } } Code: <a href="javascript:;" class="showmorelink" onmousedown="toggleDiv('checks');">Safeguarding</a> Can anyone advise? Many thanks, Greens85 I have a popup window that calls a texteditor. I want the texteditor to show the inner HTML of the parent doucument by div id. When I call the function through a submit (in child window) it workks great, but I want innerHTML to be added when child page loads. I have tried calling function in body onLoad=getparent; tries adding it to inner script where it calls the editor , again onLoad=getparent; Tried with and without () i.e onLoad=getparent(); Child window code: [code] <html> <head> <title>Mangae Content</title> <script type="text/javascript" src="/ckeditor/ckeditor.js"></script> <script language="javascript"> function getparent() { var TextToPass = window.opener.document.getElementById('missionStatement'); var TextToEdit = TextToPass.innerHTML; document.getElementById('editor1').value=TextToEdit; } </script> </head> <body> <form method="post" name="editedcontent"> <p> My Editor:<br /> <textarea name="editor1" id="editor1"></textarea> <script type="text/javascript"> onload=getparent; CKEDITOR.replace( 'editor1' ); </script> </p> <p> <input type="submit" onClick="getparent();"/> </p> </form> </body> </html> [code] When I use the submit button it works fine. Captures parent window HTML and loads it into ckeditor, How do I get it to load without using the submit button??? Any help would be greatly appreciated. while decomplicating things I putted into single jsp code like that: Code: <script language="javascript" src="../js/A.js" type="text/javascript"> </script> <script language="javascript" src="../js/B.js" type="text/javascript"> </script> The prob here is that both A and B contains window.onload, and only the one from A gets executed. All things that come to my mind is back to complications, loosing track of things. Any advice ? Hi I am in need of some help with my Javascript code, basicly I am creating a Javascript SDK for my site and I am trying to make is a little like jQuery in which you check if the document is ready such as $('document').ready(function(){}); which my SDK looks like this $.functions.push(function(){}); the only thing is when using it like this each function push gets added to the functions array which i then need to use on the documents load. With my SDK I use $.onload.ready();, which should act as window.onload and run all the functions with-in the array but I cant seem to get it to work. This is what I currently have. Code: $.functions =new Array(); $.onload = {}; $.onload.ready = function(){ if(window.onload !== undefined && window.onload != '') { window.onload=function(){for(var i=0;i<$.functions.length;i++){$.functions[i];}}; } }; Can anyone help me out? Thank You DJCMBear EDIT: Don't worry I have found the solution and it works! This is the code for the onload. Code: $.onloadAdd = function(func) { if(typeof onload == 'function') { var oldonload = onload; onload = function() { oldonload(); func(); } } else { onload = func; } }; $.onload = function(){ if(window.onload !== undefined && window.onload != '') { for(var i=0;i<arguments.length;i++) { $.onloadAdd(arguments[i]); } } }; And this is the onload functions that get added to the list to be run. Code: $.onload(function(){if($.Class('Listener')){for(i=0;i<$.Class('Listener').length;i++){$.Class('Listener')[i].onclick=function(){alert($.getInfo(this).innerHTML);};}}},function(){if($.Class('Add')){for(i=0;i<$.Class('Add').length;i++){$.Class('Add')[i].innerHTML=$.Class('Add')[i].innerHTML+'...';}}}); Hi there, I'm trying to port a pretty old javascript to a brand new Joomla website. I didn't create the original site that the javascript comes from, and haven't been able to locate it in my Google searches either. I'm assuming it's quite old. That being said, it seems to *want* to load up correctly. Since this is in an individual Joomla article, I didn't want to set the template to always try and load this script from <body>, so I'd found what I thought might be a workaround by calling it from another javascript within the article. It *looks* like it starts to want to call the required images, but then they disappear. I am not a javascript programmer in any way. I really don't do more than copy & paste various scripts of that nature. So I'm a little flummoxed here. Any help you can afford will be appreciated. Here is the development page: Mixes Thanks in advance. ~Laura Hi everyone, I am at the last leg of getting my code to run. I have a window.onload function, but right now it is working only when I fill in all the field in the drop down list, hit a refresh and then hit submit button. What changes should I implement in the code? The code after the window.onload function runs as follows: Code: window.onload = function() { age = 0; groom_age = getvalues(); caste = 0; groom_caste = getvalues_1(); profession = 0; groom_profession = getvalues_2(); bachelor = 0; groom_bachelor = getvalues_3(); master = 0; groom_master = getvalues_4(); doc = 0; groom_doc = getvalues_5(); country = 0; groom_country = getvalues_6(); color = 0; groom_color = getvalues_7(); height = 0; groom_height = getvalues_8(); marriage = 0; groom_marriage = getvalues_9(); father = 0; groom_father = getvalues_10(); switch(groom_age) { case "23" : age = 1.6; break; case "24" : age = 1.2; break; case "25" : age = 1.7; break; case "26" : age = 1.8; break; case "27" : age = 1.9; break; case "28" : age = 1.75; break; case "29" : age = 1.7; break; case "30" : age = 1.4; break; case "31-35" : age = 1.8; break; case "36-40" : age = 1.9; break; case "41-45" : age = 1.75; break; case "46-50" : age = 1.7; break; case "51+" : age = 1.4; break; default: age = 1; } switch(groom_caste) { case "Brahmin" : caste = 1.6; break; case "Bania" : caste = 1.2; break; case "Kayastha" : caste = 1.6; break; case "Kshatriya" : caste = 2.0; break; case "Dalit" : caste = 1.8; break; case "Maravar" : caste = 1.6; break; case "Mudaliar" : caste = 2.0; break; case "Jat" : caste = 1.8; break; case "Labanas" : caste = 1.6; break; case "Rajput" : caste = 1.6; break; default : caste = 1; } switch(groom_profession) { case "Engineer" : profession = 1.6; break; case "Doctor" : profession = 1.2; break; case "Lawyer" : profession = 1.65; break; case "CA" : profession = 1.7; break; case "IAS" : profession = 2.0; break; case "Family Business" : profession = 1.5; break; case "Engineer + MBA" : profession = 1.95; break; case "None of the above" : profession = 1.95; break; default: profession = 1; } switch(groom_bachelor) { case "BTech/BE/BS" : bachelor = 1.6; break; case "MBBS" : bachelor = 1.2; break; case "BA" : bachelor = 1.1; break; case "B.Com" : bachelor = 1.4; break; case "BSc" : bachelor = 1.9; break; case "BBA" : bachelor = 1.1; break; case "Diploma" : bachelor = 1.4; break; case "Certification Course" : bachelor = 1.4; break; default: bachelor = 1; } switch(groom_master) { case "MS" : master = 1.6; break; case "MBA" : master = 1.2; break; case "MHA" : master = 1.4; break; case "MTech" : master = 1.4; break; case "M.Ed" : master = 1.4; break; case "No Master degree" : master = 1.4; break; default: master = 1; } switch(groom_doc) { case "Doctor of Philosophy (Phd)" : doc = 1.6; break; case "Doctor of Medicine (MD)" : doc = 1.2; break; case "No Doctorate Degree" : doc = 1.4; break; default: doc = 1; } switch(groom_country) { case "India" : country = 1.6; break; case "USA" : country = 1.2; break; case "Any European Country" : country = 1.7; break; case "Australia" : country = 1.7; break; case "Canada" : country = 1.7; break; case "Any Country more developed than India" : country = 1.7; break; case "Any Country less developed than India" : country = 1.2; break; default: country = 1; } switch(groom_color) { case "Fairy White" : color = 1.6; break; case "Black" : color= 1.2; break; case "Wheatish (Almost White. Would need some Fair n Lovely)" : color= 1.4; break; case "Brown": color= 1.4; break; case "White": color= 1.9; break; case "Pitch Black (Not visible on a moonless night)" : color= 0.6; break; default: color = 1; } switch(groom_height) { case 'Less than 5\'4"' : height = 1.6; break; case '5\'4"' : height = 1.2; break; case '5\'5"' : height = 0.8; break; case '5\'6"' : height = 1.0; break; case '5\'7"' : height = 1.4; break; case '5\'8"' : height = 1.5; break; case '5\'9"' : height = 1.6; break; case '5\'10"' : height = 1.7; break; case '5\'11"' : height = 1.8; break; case '6' : height = 1.85; break; case '6\'1"' : height = 1.9; break; case 'Greater than 6\'1"' : height = 1.8; break; default: height = 1; } switch(groom_marriage) { case "0" : marriage = 1.6; break; case "1" : marriage = 1.2; break; case "2" : marriage = 0.4; break; case "More than 2" : marriage = 0.2; break; default: marriage = 1; } switch(groom_father) { case "Doctor" : father= 1.6; break; case "IAS" : father = 1.2; break; case "Engineer" : father= 1.7; break; case "Lawyer" : father= 1.65; break; case "CA" : father= 1.8; break; case "Engineer + MBA" : father= 1.9; break; case "Family Business" : father= 1.2; break; default : father = 1; } }; function processOrder() { var total = age + caste + bachelor + master + doc + color + profession + father + marriage + height + country; var pageNumber = Math.floor((20 - total) / 2 + 1); // pageNumber = 6; // alert(pageNumber); window.open ("Page " + pageNumber + ".html"); } </script> <center> <INPUT TYPE="button" VALUE="Calculate" onClick="processOrder()"> </center> I would really appreciate any kind of help. Thanks a lot! Hi, I am trying to give the user the option of music on my homepage (b/c we've all found it annoying at times...perhaps most times). I have found an "onload" option for the body tag on dotnetspider.com, but it doesn't seem to be working for me. Please take a look and let me know of any improvements I could make. Thx Code: <body onload="loadMusic()"> <p> <script type="text/javascript"><!-- function loadMusic() { var r=confirm("Would you like a background tune?"); if (r==true) { <input type="button" onclick="show_confirm()" value="Show a confirm box" /> <object class="plugin_video" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" height="480" width="640"> <param name="autoplay" value="false" /><embed title="QuickTime" hidden="true" src="sounds/siteBG.wav" mce_src="sounds/siteBG.wav" autoplay="true" loop="true" controller="true"></embed> </object> } else { alert("If you change your mind reload the page to choose again."); // --></script> |