JavaScript - Hiding An Iframe
hello all...just joined up...very anxious to get my website improved with some of your kind help
i have this current JS running, but Im having some little issues i thought someone here could help me out with. I want the background color to be #0f3559. But whenever I add this to the script it disables the buttons I have included. Also, I would like to have just one "Show/Hide" button that does both functions rather than 2 seperate. can anyone take a look? THANKS. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd" > <html lang='en'> <head> <meta http-equiv='Content-type' content='text/html;charset=UTF-8'> <title>ESPN SCORELINE</title> <script type="text/javascript"> function setVisibility(theId, visibility) { document.getElementById( theId ).style.visibility = visibility; } function setDisplay(theId, display) { document.getElementById( theId ).style.display = display; } </script> </head> <body> <input type="button" value="show" onclick="setVisibility('scoreline', 'visible'); "> <input type="button" value="hide" onclick="setVisibility('scoreline', 'hidden'); "> </body> <iframe src="http://espn.go.com/bottomline/espnewsbottomlinebasic.html" width="1000" height="45" frameborder="0" marginheight="0" marginwidth="0" scrolling="no" style="visibility:hidden;" alt="scoreline" id="scoreline"></iframe> </html> Similar TutorialsHi when we used to place mouse over a menu,the submenu goes downwards.The submenu is not visible in one page as it is hided by an iframe which contains the pdf. Is there any way to over this Bug in order to display the the submenu over the iframe. the link with this error is http://www.rosarychurchqatar.com/lec...pg=roster&id=2 Any help will be appreciated Regards Rajeev Hi there everybody, I've got this problem which I can't solve myself... I've got a website which has 3 colums and is hosted on domain1.com. in the right column I've got an Iframe which loads content from domain2.com . this content are some textboxes and a datepicker tool. if I press the 'search'-button in this Iframe I would like to refresh the mainpage (from domain1.com) so that another Iframe appears in the middle column. in this column i would like to load a new form from domain2.com which contains the values that I've put in in the form from the right Iframe. Unfortunally I can't get this to work... Will somebody please help me? Is there a way to resize an iframe dynamically so that you never get the scroll bar and essentially hide that there is an iframe? Better integration really. Basically I want to iframe a forum into my site so that the design down the sides and top which my friend does using iweb are not messed with. We have a central area which can be longer or shorter depending on the forum. Hi all, I hope you can help I have some code which: 1) Opens a URL (e.g. google.com) in a hidden iframe, then 2) Redirects the visitor to a different URL (e.g. yahoo.com) after it has loaded... This works exactly as I need. What I'd like to do is the following: 1) Open a URL (e.g. google.com) in a hidden iframe, then 2) Redirect the visitor to a different URL (e.g. yahoo.com) in a full-screen iframe 3) The address bar of the full-screen iframe should be my domain (obviously!) Here's what I have so far... Hidden iframe -> New URL Code: Code: <html> <body> <script type="text/javascript"> var page_body = document.getElementsByTagName('body'); var myframe = document.createElement('iframe'); var id = Math.random(); myframe.setAttribute('id', 'myFrame'+id); myframe.src = 'http://google.com'; //First open Google in hidden iframe myframe.setAttribute('frameborder', '0') myframe.setAttribute('width', '0'); myframe.setAttribute('height', '0'); if (myframe.attachEvent) { myframe.attachEvent('onload', function() { top.location = 'http://yahoo.com'; //Once loaded redirect to Yahoo -- but the address bar shows yahoo.com -- I want the address bar to display mydomain.com/page.html }); } else if (myframe.addEventListener) { myframe.addEventListener('load', function() { top.location = ('http://yahoo.com'); }, false); } page_body[0].appendChild(myframe); </script> </body> </html> I have an example of some code which displays the full screen iframe, but my problem is... ...I can't figure out how to redirect to this after the hidden iframe has loaded Here's an example of how I want the redirect to display -- after the initial hidden iframe has loaded: Code: <html> <head> <script type="text/javascript"> function sendParams() { document.body.style.overflow = "hidden"; } </script> </head> <body> <!--Open Yahoo.com in a full screen iframe, and disable extra scrollbar --> <iframe height="100%" width="100%" frameBorder="no" onload="sendParams()" src="http://yahoo.com"></iframe> </body> </html> I've been beating my head against the wall today trying to figure this out, and I'm fresh out of ideas. If you can help, you'll have some serious gratitude and good karma thrown your way! Best wishes, and thanks in advance, Paul I have used iframes for my site and found various javascripts so when a person clicks on say the audio page he http://www.krillmeed.com/index.html it takes them to the audio page but will load it into the index.html page. The problem is, especially with search engines, to point to that page, this is what the URL looks like to send someone to that page: http://www.krillmeed.com/?frame=0&sr...m%2Faudio.html which is not very clean at all, this is the javascript that i found that at least works: Child iframe script: Code: <script type="text/javascript"> (function(){ var qstr = '?frame=0&src=' + encodeURIComponent(location.href), lre = new RegExp('^' + location.protocol + '//' + location.hostname + '(()|(/)|(/index.html)|(/index.php))(()|(\\' + qstr + '))$'); if (!lre.test(parent.location.href)){ top.location.href = '/' + qstr; } })(); </script> Parent iframe Script: Code: <script type="text/javascript"> (function(){ function getQval(n) { if(typeof n !== 'string'){ return null; } var r = new RegExp('[?&;]' + n + '=([^&;#]*)'), m = location.search; return (m = r.exec(m))? unescape(m[1]) : null; } var f = getQval('frame'), s = getQval('src'); if(f && frames[f] && s && s.indexOf(location.protocol + '//' + location.hostname + '/') === 0){ frames[f].location.href = s; } })(); </script> Is there a "cleaner" way of doing this? This was an old code, i have yet to find a more modern one. Thank you in advance. Hello All, I am new to this forum and to web development, I am trying to hide div based on conditions.. This is the scenario: the div should never appear again for that user, until i write another server side message. lets say i write a message today saying " we are really sorry, but the website will be don for one hour today" and you login today, the message will be displayed, when you click close its closed, it wont appear again for you, until i post another message, but each message would have an expiration date, if i post a message which would be displayed to every user, i should decide how long i want it displayed, maybe 24 hrs, so in 24 hrs the message should no longer display. Please help me out on this...I need a solution fast... Thanks Hi, I got a table with hundreds of rows...and I want the user to be able to hide a single one by clicking on the table row. How can I do this without typing in hundreds of ids like 1,2,3,4,5... Since you can't get elements by class and ids have to unique I'm not sure how to do this. Also the order of the rows will change when they get updated so it would end up being a mess of unordered ids. Thanks. Hi, If I want to hide a title / heading if a field below is not filled in, what would be the js for that? I have an "Attachments" h2 heading and three following fields for the client to add up to three attachments. But if none are filled in I want the h2 heading to not display. This is what I have so far: var attachment1 ='{tag_attachment 1}' var attachment2 ='{tag_attachment 2}' var attachment3 ='{tag_attachment 3}' === if(attachment1 == '') { document.getElementById('attachment1').style.display = 'none'; } if(attachment2 == '') { document.getElementById('attachment2').style.display = 'none'; } if(attachment3 == '') { document.getElementById('attachment3').style.display = 'none'; } === <div id="attachments"> <h2>Attachments</h2> <p>{tag_attachment 1}<br /> {tag_attachment 2}<br /> {tag_attachment 3}</p> </div> This should take care of the three fields, but how do I tie in the heading too? Thank you! Hi, Would someone here please help me with this script. I know I am a complete hack at this, but I need to get it to work. Your help is appreciated. As you can see, based on the if statement, I need to leave the Div element below hidden, or un-hide it. I know the first part works. The second part (after "else" ) is where I am having the problem. Code: <td> <script type="text/javascript"> if ([fieldXX]==1) { document.write("<a href='page1.asp?itemid=1234'><img src='images/btn-choose.gif' border='0' alt='choose button'</a>"); } else { var id = 'hide-buy-btn'; var item = document.getElementById(id); if (item) { item.className=(item.className=='hidden')?'unhidden':'hidden'; } } </script> <div id="hide-buy-btn" class="hidden"> x xother button code x </div> </td> i am having some problem showing and hiding some div i want to show the div with the id="universitiesDiv" on one point and the div id="highSchoolsDiv" on another depending on the user choice of selected option. Code: function Show (titleImg){ // the id of the content element from the id of the title element var contentID = titleImg.id.replace (/title/, "content"); var contentDiv = document.getElementById (contentID); contentDiv.style.display = "block"; return false; } function Hide (titleImg){ // the id of the content element from the id of the title element var contentID = titleImg.id.replace (/title/, "content"); var contentDiv = document.getElementById (contentID); contentDiv.style.display = "none"; return false; } the functions work fine i have tested them on input type="checkbox" and they work fine Code: <select name="education" id="education" onfocus="Show(this.options[this.selectedIndex].value);"> <option selected value="00">-الرجاء الاختيار-</option> <option value="highSchoolsDiv">مدرسة ثانوية</option> <option value="universitiesDiv"> كلية </option> <option value="universitiesDiv">درجة البكالوريوس</option> <option value="universitiesDiv">درجة عليا</option> <option value="universitiesDiv">دكتوراه / ما بعد الدكتوراه</option> <option value="07">اسألني فيما بعد</option> </select> </span> </div> </td></tr></table> </div> <div> <div class="Left"></div> <table class="step2" ><tr><td> <div class="Right"> <div class="Inner" id="Inner"> <div id="universitiesDiv" class="Row innerError" style="display:none;"> <div class="Left"> <label for="universities">الجامعة / الكلية</label></div> <div class="Right"> <input type="text" name="universities" id="universities" class="text" autocomplete="off" onfocus="focusInput(this);" onchange=" validate_JoinPersonalInfoForm_universities();" onblur="blurInput(this); validate_JoinPersonalInfoForm_universities();" size="55"/> </div> </td></tr><tr><td> </div> <div id="highSchoolsDiv" class="Row innerError" style="display:none;"> <div class="Left"> <label for="high_schools">المدرسة الثانوية</label></div> <div class="Right"> <input type="text" name="high_schools" id="high_schools" class="text" autocomplete="off" onfocus="focusInput(this);" onchange=" validate_JoinPersonalInfoForm_high_schools();" onblur="blurInput(this); validate_JoinPersonalInfoForm_high_schools();" size="55"/> </div> </div> </div> </div> </td></tr></table> </div> here is doesn't do nothing i have tried onblur onfocus onchange onselect everything i even tried then in side the option <option onselect... !!!!! anyone can help me, that would be great thanks OK, I've been working on this for quite some time now, and have it working, almost. lol. Hopefully someone here can lend a fresh pair of eyes to what I'm doing wrong (bare in mind, I don't know javascript very well at all). I'm creating a simple faq page for my site, but there's a lot of questions, so instead of lumping it all in at once, I'm using divs to store answers in that hide and reappear as my guests click on a question they want to see an answer too. ok, heres the basics of the code I'm using so far: Code: <script type="text/javascript"> function showit(boxName) { theBox = document.getElementById(boxName); theBox.className = "boxVisible"; } </script> <script type="text/javascript"> function hideit(boxName) { theBox = document.getElementById(boxName); theBox.className = "boxHidden"; } </script> That, is in the head section of my page. Then for the links and such I have: Code: <div><a href="link.html" onclick="showit('s11'); hideit('s12'); hideit('s13'); hideit('s14'); hideit('s15'); hideit('s16'); return false;">Do you shoot in color, or black and white?</a></div> <div id="s11"> We shoot in color. Color prints can be printed in black and white and come out perfectly just as though they were shot in black and white. However if you shoot in black and white, you can't print it in color. For this reason we shoot all of our images in full color. </div> obviously there are more questions that that, but I don't want to fill this screen with all of them either. Ok, heres what its doing, when you click on the first question, no problem, the answer opens right up, appears where it should be, everythings great, except, that its also following the link and leaving the page. I get to a 404 error telling me that link.html does not exist on my server. So, apparently the Code: return false isnt working.... what do I need to do here, I'm now lost... OH, I should include the CSS I'm using for these DIV's so you can see what the javascript is calling on for them: Code: .boxVisible { display: block; position:relative; left:25px; width:755px; overflow:auto; } .boxHidden { display: none; } Thanks to ANYONE that can help out! I don't mean for this to be an advertisement, and if its not allowed by all means I'll remove it from this post, but if you want to see my exact code that I'm using, you'll find the page I'm working on at http://www.smmahoney.com/index.php?page=faq 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 this simple checkbox menu http://myresearchfinder.com/dev/checktest.html If you check the cancer box a div will appear. If you check lung, another menu pops up. If you check colon nothing appears because it's behind the lung div. I am aware of z-index. But because a person may go back and forth between menus I need a way to make sure the appropriate div is always on top. Any ideas? Hi, I wondering if anyone can help: I've got rows of divs in this manner <div class="row">This is row 1 <a href="click">click here to show more</a></div> <div class="hidden row"><p> hidden text for row 1</p></div> <div class="row">This is row 2 <a href="click">click here to show more</a></div> <div class="hidden row"><p> hidden text for row 2</p></div> <div class="row">This is row 3 <a href="click">click here to show more</a></div> <div class="hidden row"><p> hidden text for row 3</p></div> <div class="row">This is row 4 <a href="click">click here to show more</a></div> <div class="hidden row"><p> hidden text for row 4</p></div> I wish to have some javascript to toggle the hidden row for its corresponding link. Please can someone help point me to an example if available. Any help will be greatly appreciated Hi guys, I am working with a plugin calld Hashslider which is a fairly simple div slider. Here is the code for startrs Code: // hashslider v0.9 by manuel huegel, copyright 2010 // mgoys.com $(document).ready(function(){ //get width and height of the wrapper and give it to the UL var wrapperwidth = $('#slider').width() * $('#slider ul > li').size(); $('#slider ul').css('width', wrapperwidth); var wrapperheight = $('#slider').height(); $('#slider ul').css('height', wrapperheight); //set my li width var width = $('#slider').width(); $('#slider ul li').css('width', width); //set my counter vars var counter = $('#slider ul > li').size(); var decount = 1; var autocount = 1; //create my number navigation var createNum = 1; $('#numbers li:first-child').html(createNum).addClass('activenum').attr('id', 'id1'); while ( createNum != counter) { $('#numbers li:last-child').after('<li> </li>'); createNum++; $('#numbers li:last-child').html(createNum); $('#numbers li:last-child').attr('id', 'id' + createNum); } //get my number-width (number navigation should always be centered) var numwidth = $('#numbers li:first-child').width() * $('#numbers li').size(); $('#numbers').css('width', numwidth); //slide the button to the next item function goNext() { if ( decount != counter) { $('#slider ul').animate({ left: '-=' + $('#slider').width() }, 400, 'swing', function() { }); $('.activenum').removeClass('activenum').next().addClass('activenum'); decount++; window.location.hash = decount; } } function goBack() { if ( decount != 1) { $('#slider ul').animate({ left: '+=' + $('#slider').width() }, 400, 'swing', function() { }); $('.activenum').removeClass('activenum').prev().addClass('activenum'); decount--; window.location.hash = decount; } } //make the number clickable $("#numbers li").click(function() { //$('#info4').html( $(this).html() ); var clickednum = $(this).html() * - $('#slider').width() + $('#slider').width(); //$('#info4').html( clickednum ); $('#slider ul').animate({ left: clickednum }, 400, 'swing', function() { }); $('.activenum').removeClass('activenum'); $(this).addClass('activenum'); decount = $(this).html(); window.location.hash = $(this).html(); }); //thaths the hash-shizzle if ( window.location.hash != '') { //get hash, scroll to position var hashnum = window.location.hash.substr(1) * - $('#slider').width() + $('#slider').width(); $('#slider ul').animate({ left: hashnum }, 0, function() { }); //set counters to position decount = window.location.hash.substr(1); $('.activenum').removeClass('activenum'); var hashname = window.location.hash.substr(1); $('#id' + hashname).addClass('activenum'); } //get my clickers $("#right").click(function() { goNext(); }); $("#left").click(function() { goBack(); }); //get mousewheel function $("#slider ul").mousewheel(function(event, delta) { if (delta > 0) { goBack(); event.stopPropagation();event.preventDefault(); } }); $("#slider ul").mousewheel(function(event, delta) { if (delta < 0) { goNext(); event.stopPropagation();event.preventDefault(); } }); }); As you will see the current code loops through all of the slides, and when it reaches the last (or first) the previous and next links become unclickable. I would like to go a stage further than this and make them dissapear entirely. I don't know how to do this or even to start, I dont even know what function to edit. Please help guys. Thanks in advance Dan This might not be as simple as the title suggests. It may be a CSS problem, please say so if you know it to be and I will move it to the correct forum. Now for the question, Please visit: http://danielrhyshardy.com/header/demo.html I am using the jquery plugin supersized to create a carousel of images in the background of the page. As you will see though, as the transition starts, the second image is visible. I only want it to be visible when it indeed starts to overlap the current image. (i.e when the bench image overlaps the trees etc) Here is the CSS: Code: * { margin:0; padding:0; } body { background:#111; height:100%; } img{ border:none; } #supersized { position:absolute; left:0; top:0; overflow:hidden; z-index:-999; height:50%; width:100%; } #supersized img{ width:auto; height:auto; position:relative; display:none; outline:none; border:none; } #supersized.speed img { -ms-interpolation-mode:nearest-neighbor; image-rendering: -moz-crisp-edges; } /*Speed*/ #supersized.quality img { -ms-interpolation-mode:bicubic; image-rendering: optimizeQuality; } /*Quality*/ #supersized a { z-index:-30; position:fixed; overflow:hidden; top:0; left:0; width:100%; height:50%; background:#111; display:block; } #supersized a.prevslide { z-index:-20; } #supersized a.activeslide { z-index:-10; } #supersized a.image-loading { background:#111 url(../img/progress.gif) no-repeat center center; width:100%; height:50%; } #supersized a.prevslide img, #supersized a.activeslide img{ display:inline; } Thanks guys Dan I have a simple password protection setup on my site but the password is displayed when it is typed in is there a way to change it to a # or * when it is typed in
hey all, Registered for this forum because I found this thread about hiding and unhiding divs. http://www.codingforums.com/archive/.../t-161166.html I have tried to implement this on a site that I am building and have come up with a weird result. My javascript is very poor so debugging this has become a real headache. Hopefully someone can help out. The issue is that when I click the button to unhide the hidden div, it hides everything and reveals the hidden div on its own without everything else. Hopefully that makes sense. Current code looks as follows- Code: <script type="text/javascript"> function unhide(divID) { var divs=document.getElementById('wrap').getElementsByTagName('div'); for(var i=0;i<divs.length;i++) divs[i].className='hidden'; var item = document.getElementById(divID); if (item) { item.className=(item.className=='hidden')?'unhidden':'hidden'; } } </script> <style type="text/css"> .hidden { display: none; } .unhidden { display: block; } </style> </head> <body> <div class="container" id="wrap"> <!-- MODULE START --> <div id="web" class="panelContainer"> <div id="panelBtnContainer"> <li><a href="#" onclick="unhide('test1'); return false;" class="web"><span>Button Text</span></a></li> </div> <div class="leftContainer"> <div class="panelShadow"></div> <div class="panelThumb"> <img src="images/works/t-test.jpg" height="233" width="300" alt="Test Thumbnail" title="Test Thumbnail" /> </div> </div> <div class="rightContainer"> <h2>Neque porro quisquam est qui dolorem adipisci velit</h2> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis. </div> </div> <div id="test1" class="hidden"> <p>Testing :)</p> </div> <!-- MODULE END --> <!-- MODULE START --> <div id="web" class="panelContainer"> <div id="panelBtnContainer"> <li><a href="#" onclick="unhide('test2'); return false;" class="web"><span>Button Text</span></a></li> </div> <div class="leftContainer"> <div class="panelShadow"></div> <div class="panelThumb"> <img src="images/works/t-test02.jpg" height="233" width="300" alt="Test Thumbnail" title="Test Thumbnail" /> </div> </div> <div class="rightContainer"> <h2>Neque porro quisquam est qui dolorem adipisci velit</h2> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis. </div> </div> <div id="test2" class="hidden"> <p>Testing :)</p> </div> <!-- MODULE END --> </div> Any help would be greatly appreciated. Thanks in advanced I want it to hide or kill the div box with an onmouseout I've tried listeners functions and just plain vars. i can find a solution maybe here this is the code in the external file Code: //////////////////////////////////////////////////////// //////////////////////////////////////////////////////// function move_box(an, box) { var cleft = 0; var ctop = 0; var obj = an; while (obj.offsetParent) { cleft += obj.offsetLeft; ctop += obj.offsetTop; obj = obj.offsetParent; } box.style.left = cleft + 'px'; ctop += an.offsetHeight + 8; if (document.body.currentStyle && document.body.currentStyle['marginTop']) { ctop += parseInt( document.body.currentStyle['marginTop']); } box.style.top = ctop + 'px'; } function show_hide_box (an, width, height, borderStyle) { var href = an.href; var boxdiv = document.getElementById(href); if (boxdiv != null) { if (boxdiv.style.display=='none') { move_box(an, boxdiv); boxdiv.style.display='block'; } else boxdiv.style.display='none'; return false; } boxdiv = document.createElement('div'); boxdiv.setAttribute('id', href); boxdiv.style.display = 'block'; boxdiv.style.position = 'absolute'; boxdiv.style.width = width + 'px'; boxdiv.style.height = height + 'px'; boxdiv.style.border = borderStyle; boxdiv.style.backgroundColor = '#fff'; var contents = document.createElement('iframe'); contents.scrolling = 'no'; contents.frameBorder = '0'; contents.style.width = width + 'px'; contents.style.height = height + 'px'; contents.src = href; boxdiv.appendChild(contents); document.body.appendChild(boxdiv); move_box(an, boxdiv); boxdiv.addEventListener('mouseout', show_hide_box(boxdiv),false); return false; } //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// And you put this code in the body to call it. Code: /////////////////////////////////////////////////////////////////// <a href="../Menus/cleaners.html" onMouseOver="return show_hide_box(this,416,124,'2px')" >Cleaners</a> /////////////////////////////////////////////////////////////////// I am trying to make an order form I am working on accessible for users who have javascript turned off in their browser, and to do this I would like to hide a div if JS is disabled. Searching the Web has led me to think that styling the div to not display is the way forward and then using JS to display it. It is the JS bit I am struggling with! The div in question is a set of radio buttons to allow a purchaser to choose how many gift memberships they want to buy: Code: <div id="giftmember-buttons" style="display:none";> <h2 class="threepeaksform">How many gift memberships do you wish to purchase?</h2> <fieldset class="threepeaksform"> <legend>Please select the number of people you are buying a gift membership for using the buttons below.</legend> <div class="generalcontactform-group"> <label>1</label><input name="numbergift" type="radio" value="1" checked="checked" onClick="showhidefields(this.value)" /> <label>2</label><input name="numbergift" type="radio" value="2" onClick="showhidefields(this.value);"/> <label>3</label><input name="numbergift" type="radio" value="3" onClick="showhidefields(this.value);"/> <label>4</label><input name="numbergift" type="radio" value="4" onClick="showhidefields(this.value);"/> </fieldset> </div> <br /> </div> I have used a JS switch function lower down the page but that relies on onClick to make it work, I want the above div to display as the page loads - would I do this with the switch function and onLoad applied to the body to make the div display when JS is on? The full page is at: http://yd97.peak1.titaninternet.co.u...sform-gift.htm Thanks for any help. Cheers Stu |