JavaScript - Hide Iframe Checking If Src Is Null Or With Address
<div class="check">
<iframe src=""></iframe> </div> Hello, As subject, unfortunately I cannot touch the html, but I can only add javascript possibly in the end of the html file. I have only the class check as reference, and cannot add any id or class into iframe, it's not a button, it should load with the page and check if it should display or not the iframe. I need to create a condition as the following I think: if (iframe.src equal to null) then display:none the div class check else do nothing. Hope you can help Thank you. Similar TutorialsI need to check to see if a cookie has been previously created: Code: var startnum = readCookie('a1'); if (document.cookie.indexOf('a1') == -1){ var startnum = "0"; } Should line 2 be: Code: if (document.cookie.indexOf('a1') == null){ ? Does == -1 do the same thing? I am using the following script on an e-commerce site to ensure that not both drop downs cannot be selected at the same time, as well as ensuring one must be selected at all times. Code: <script language="javascript"><!-- function validate(cart_quantity) { if (((cart_quantity.elements['id[2]'].value == 9999) && (cart_quantity.elements['id[3]'].value == 9999)) || ((cart_quantity.elements['id[2]'].value != 9999) && (cart_quantity.elements['id[3]'].value != 9999))) { alert('Please select only one option!'); cart_quantity.elements['id[2]'].value = 9999; cart_quantity.elements['id[3]'].value = 9999; cart_quantity.elements['id[2]'].focus(); return false; } } //--></script> The initial value of the drop down is set to 9999 off the bat. The problem with this code is that not all of my product pages have these 2 drop downs so I wanted to try and add in an if statement saying that if id2=9999 and id3 == null then pop up the error. That didnt work because I don't think it can be equal to null if it does not exist on the page. So instead I tried to do the following: Code: <script language="javascript"><!-- function validate(cart_quantity) { cart_quantity.elements['id[3]'] = 99999; if (((cart_quantity.elements['id[2]'].value == 9999) && (cart_quantity.elements['id[3]'].value == 9999)) || ((cart_quantity.elements['id[2]'].value != 9999) && (cart_quantity.elements['id[3]'].value != 9999))) { alert('Please select only one option!'); cart_quantity.elements['id[2]'].value = 9999; cart_quantity.elements['id[3]'].value = 9999; cart_quantity.elements['id[2]'].focus(); return false; } if (((cart_quantity.elements['id[2]'].value == 9999) && (cart_quantity.elements['id[3]'].value == 99999))) alert('Please select an option!'); cart_quantity.elements['id[2]'].value = 9999; return false; } //--></script> I tried to assign id3 a value of 99999 so that on pages that it doesnt get reassigned after (i.e pages it does not exist on) it will still be equal to 99999 and pop up the error according to the second if clause. Unfortunately that did not work either. Is there any other way I can do via javascript? Hi, im having a little difficulty checking if an XML node has a value, here the code: var Divs=new Array("artist","bio","img","date","tickets","venue","street","city","country","headliner"); xmlDoc=xmlhttp.responseXML; for ( nodes in Divs ) { if(!xmlDoc.getElementsByTagName(Divs[nodes])[0].childNodes[0].nodeValue) { } else { document.getElementById(Divs[nodes]).innerHTML= xmlDoc.getElementsByTagName(Divs[nodes])[0].childNodes[0].nodeValue+"<br>"; } } This always throws up the error: document.getElementById(Divs[nodes]) is null ive tried putting the xmlDoc in a variable then checking if its null but no luck, also tried the same method against "undefined" but no luck either. Would be greatful if anyone has any suggestions. Thanks, Tom. hi! i am doing a site using jquery address deep linking and within the content i need to implement a show/hide div function but it doesn't seems to be working. jquery address source: http://www.asual.com/jquery/address/ demo: http://www.asual.com/jquery/address/...tabs/#Overview my show/hide div: <a href="javascript:toggle('clickHere','here' true)">click here</a> <div id="here" style="visibility:hidden; display:none">xxxx</div> function toggle(target,imgname, isOn){ window.onresize = null; obj=document.getElementById(target); obj2=document.getElementById(imgname); if(isOn){ obj.style.visibility='hidden'; obj.style.display='none'; obj2.style.visibility='visible'; obj2.style.display='inline'; } else{ obj.style.visibility='visible'; obj.style.display='inline'; obj2.style.visibility='hidden'; obj2.style.display='none'; } } * the same set of show/hide codes work when the site is not implemented with jquery address (deep linking) * so what could be the issue here? please help! Hi all I want to hide address bar for pop up window. I have used following script. In Linux machine its working fine. But in Windows machine address bar still displaying. I dont know whats the wrong. Please help me out. This is the code <script> function openNewWindow(url) { window.open (url,"",'width=620,height=300,scrollbars=yes,menubar=no,location=no'); } </script> <a href="javascript:void(0);" onclick="return openNewWindow('some url')">Click here</a> Hi, im having a problem loading a webpage inside a frameset. This frameset is inside an iframe. when i click the link in menu, it creates an iframe that load a frameset page (with two frames), the upper frame loads a webpage, this webpage in the body onLoad calls a javascript and passes a name of a webpage that must load in the other frame, the problem im facing is in the javascript, it returns null. this is the code. Code: function doLoad(url) { var iFrameContent = document.getElementById('iframeContenido'); iFrameContent.document.getElementsByName('statuszone') = url; return; } where 'iframeContenido' is the ID of the iframe that loads the frameset. statuszone is the name tag of the frame where the url must be loaded. this url is in the same domain. why is this null? any suggestions? thanks in advance! Hi there, i really could use the help. Ok, so (and im sure i will be told other ways) i have come up with a way of blocking people from my site even if they are currently on the site and dont reload the page. What i was thinking of is simply: a tiny iframe on the bottom of my page, so small it cant be seen ie 1px that iframe goes to a page saying YOU HAVE BEEN BANNED That page istself will be on a constant 10 seccond refresh so as soon as i add the ip address to it, BOOM, it will break out of the iframe and take the user away from the main page as display the you have been banned message. Sound good? ok, so here is what i have sofar but i know its wrong, dont really know how to write it correctly. The main point is: if ip is 111.111.111 then break out of iframe else do nothing. Thanks for the help. Code: <script language="JavaScript"> VIH_ForeColor = "navy"; VIH_FontPix = "16"; VIH_DisplayFormat = "%%IP%%"; VIH_DisplayOnPage = "no"; </script> <script language="JavaScript" src="http://scripts.hashemian.com/js/visitorIPHOST.js.php"></script> <script language="JavaScript" src="http://scripts.hashemian.com/js/visitorIPHOST.js.php"></script> <script> if (VIH_HostIP == "111.111.111.111") document.write('if (top.location!= self.location) { top.location = self.location.href }' ); }else{ document.write(''); ;} </script> Hi there, i really could use the help. Ok, so (and im sure i will be told other ways) i have come up with a way of blocking people from my site even if they are currently on the site and dont reload the page. What i was thinking of is simply: a tiny iframe on the bottom of my page, so small it cant be seen ie 1px that iframe goes to a page saying YOU HAVE BEEN BANNED That page istself will be on a constant 10 seccond refresh so as soon as i add the ip address to it, BOOM, it will break out of the iframe and take the user away from the main page as display the you have been banned message. Sound good? ok, so here is what i have sofar but i know its wrong, dont really know how to write it correctly. The main point is: if ip is 111.111.111 then break out of iframe else do nothing. Thanks for the help. Code: <script language="JavaScript"> VIH_ForeColor = "navy"; VIH_FontPix = "16"; VIH_DisplayFormat = "%%IP%%"; VIH_DisplayOnPage = "no"; </script> <script language="JavaScript" src="http://scripts.hashemian.com/js/visitorIPHOST.js.php"></script> <script language="JavaScript" src="http://scripts.hashemian.com/js/visitorIPHOST.js.php"></script> <script> if (VIH_HostIP == "111.111.111.111") document.write('if (top.location!= self.location) { top.location = self.location.href }' ); }else{ document.write(''); ;} </script> Hi, I'm currently developing an application (in php) for a website that is to be integrated into their website using iframe. It's imperative that it's done using iframe as I am placing the application on my own server. In short, the iframe element appears on my customer's website (lets say customer.com) - something like this: <iframe width="440" height="500" frameborder="0" scrolling="no" src="http://www.myserver.com/index.php"></iframe> However, it's quite imperative that my application (i.e. what's located at myserver.com/index.php) only can be shown in iframe elements placed at customer.com. That is: I want to make sure that a similar iframe element from another web server (lets say anothercompany.com) has the possibility to iframe my application located at myserver.com. My first idea was to check this using php in my application: by looking at HTTP_REFERER, I can get the location of the page containing the iframe element. That solution seems to work fine. However, as is well known, it is possible to spoof and even hide the http_referer server variable. Still, as I only want to make sure that no other server accesses the application through an iframe object, it should perhaps be an okay solution - if someone wants to access the application from their own browser, and spoofing the HTTP_REFERER variable, I'm fine with that. (I just want to make sure that only customer.com, and not anothercompany.com, can integrate the application with an iframe). The other thought I had was to use javascript and DOM stuff. The idea is then to use javascript to check that the application has a parent frame and that its location is at customer.com. However, as we are dealing with two different domains here, I'm having a lot of problems getting the document.parent.location variable - it's not allowed! Any solutions on how to do this in javascript? Any way to bypass the obstacle above? Or perhaps javascript isn't the best way? My guess is that there is a solution out there somewhere - I guess there are a lot of ads that are integrated into various websites using iframe, and where the actual content (i.e. what's inside the iframe element) can check which server is embedding the ad through an iframe element. I want to be able to hide a DIV within an iframe from the parent document. The usual document.getElementById('element').style.display="none"; doesn't work as I can't point to elements within the iframe with it. What do I need to add to make it look within the iframe and not the parent document? Many thanks in advance. I have this iframe code. Code: <iframe width="300" height="180" style="margin-bottom:5px; z-index:-1000;" src="http://www.ichartsonline.com/external/tradeback.aspx" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe> I have a WP plugin for image lightboxes. When the lightbox pops up, the iframe is overlayed on it. Is there any easy fix for this? Do you need to see the plugin Javascript? Any help will be much appreciated! Thanks I have in my HTML/CSS an iFrame that is hidden by default. You click a link to make it visible using MM_showHideLayers. What I need to do is make a link work from within that iFrame that makes it hidden again. Any takers? Thanks - Chris B. I'm setting up an application that involves blog posts with comments boxes appended to the div that contains the posts. The comments boxes are in iframes and load an html file on the same domain. There are multiple posts/boxes on each page. I need a javascript that will only run the append script when the posts are written and appear on the page. So in non js language, I'm looking for this: if div id post#5 appears on the page, show the iframe that contains the comments box that goes with post number 5. else don't show it. I don't know enough javascript to figure this out so if anyone could point me in the right direction, I'd be grateful. Hello codingforums, There are various widgets and plugins that show link preview via tooltip or iframe, So as I am trying to continuously improve web sites experience with new trends and web functionalities - thus it come the task for uniform link preview via div and iframe. This is the script that use attribute id's but for the complete solution it would be required to display link within event 'this' or something -any suggestions and help are very appreciated. Thanks Code: <script type="text/javascript"> function toggleDiv(divid){ var div = document.getElementById(divid); div.style.display = div.style.display == 'block' ? 'none' : 'block'; } </script> <div class="toggle"><a href="javascript:toggleDiv('panel1');" >Toggle Panel 1</a></div> <div id="panel1" class="panel"> <h2>Panel 1</h2> This panel contains text </div> <div class="toggle"><a href="javascript:toggleDiv('panel2');" >Toggle Panel 2</a></div> <div id="panel2" class="panel" style="display:block;"> <h2>Panel 2</h2> This panel contains external url content <iframe src="http://" width="100%" heigth="500"></iframe> </div> <div id="panel1" class="panel"> <h2>Panel 1</h2> This panel starts closed because style='display:none' is defined in the style section of the head </div> <div class="toggle"><a href="javascript:toggleDiv('panel2');" >Toggle Panel 2</a></div> <div id="panel2" class="panel" style="display:block;"> <h2>Panel 1</h2> This panel starts open because of style='display:block' </div> <a href="javascript:toggleDiv('panel1');" >Another Link to Toggle Panel 1</a> [/CODE] Though I took out the source of the iframe, I get an error when I click the test button to get the value of msg_title. I am using IExplorer to debug it, as firefox doesnt show the error. Code: <script type='text/javascript'> function test(){ page = window.location.href document.getElementById('1').value = window.frames[2].document.getElementByName('msg_title').value } function apple(){ document.getElementById('3').innerHTML = '<iframe src="" name="4" id="4"></iframe>' } window.onLoad = test(); </script> <div id='3' name='3'></div> <input type='button' value='apple' name='apple' id='apple' onclick='apple()'> <input type='button' value='test' name='test' id='test' onclick='test()'> <input type='text' value='' name='1' id='1'> <br> <iframe src='' name='2' id='2'> Hi I am having trouble with a script. I cannot figure out why I get the message: error: null is null or not an object (In IE8) The site is: www.rayburns.com I have check the javascript for the navigation bar and for the rotating images and cannot see what is missing. Not sure what is not being called. Can someone please help with this. Thank you in advance! Hi i have done some reading on the net today because i am getting an error on ie. I did find the javascript twice in my code, once in the header and once here, so i removed it from the header. I also changed to src to the full url. But i am still getting this and i dont know why. the file is located in the root directory. Code: Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; SearchToolbar 1.2; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; msn OptimizedIE8;ENUS) Timestamp: Sat, 30 Jul 2011 16:03:05 UTC Message: 'null' is null or not an object Line: 8 Char: 3894 Code: 0 URI: http://www.mysite.com/swfobject.js Code: <script type='text/javascript' src='$CONST_LINK_ROOT/swfobject.js'></script> <script type='text/javascript'> var s1 = new SWFObject('player.swf','player','400','300','9'); s1.addParam('allowfullscreen','true'); s1.addParam('allowscriptaccess','always'); s1.addParam('flashvars','file=$CONST_LINK_ROOT/movies/$sql_array->vid_id.flv'); s1.write('preview'); </script> <embed src='$CONST_LINK_ROOT/flvplayer.swf?file=$CONST_LINK_ROOT/movies/$sql_array->vid_id.flv&autoStart=false' width='175' height='175' quality='high' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'></embed> would appreciate any suggestions thanks. i was on 1.5 swfobject i did download 2.2 and im guessing all you do is replace the swfobject.js file to upgrade it, but what happened is it gives me this now. Code: Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; SearchToolbar 1.2; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; msn OptimizedIE8;ENUS) Timestamp: Sat, 30 Jul 2011 16:31:08 UTC Message: 'SWFObject' is undefined Line: 1283 Char: 1 Code: 0 URI: http://www.mysite/video_admin.php?type=v i dont mind going back to the old version i just need to get this working and im soooooooo lost lol ok another update, this is becomming maddening lol. once i have this line in the header php Code: <script type='text/javascript' src='$CONST_LINK_ROOT/swfobject.js'></script> I never have to use it again as long as they header php is included correct? This is what is driving me nuts, im back on 1.5 and it says its undefined Code: but am in not defining it on this line? ---> var s1 = new SWFObject('player.swf','player','400','300','9'); <script type='text/javascript' src='swfobject.js'></script> <script type='text/javascript'> var s1 = new SWFObject('player.swf','player','400','300','9'); s1.addParam('allowfullscreen','true'); s1.addParam('allowscriptaccess','always'); s1.addParam('flashvars','file=$CONST_LINK_ROOT/movies/$sql_array->vid_id.flv'); s1.write('preview'); </script> Another Update. I am back to the original question. null is null or not an object.. in my search i have found this found a solution. basically Internet Explorer is crappy and doesnt like the setAttribute property so had to change the onchange handler by directly changing the attrbute for the object like so. object.onchange = function() {} i have no idea what they means, does that mean i need to change swfobject.js or does that mean i have to change my xml request. and if it is the swfobject i have no clue what they mean or what lines Hi I've implemented Busybox on a website to display FLV files in a popup player. This works fine, except for the following error in IE (FF is fine) when I close the popup: 'null' is null or not an object I think I've narrowed it down to the following block of code, but am stuck as to what to do from here. Code: var cl = new Element('img',{ 'styles':{ width:'24px', height:'24px', position:'absolute', top:'-20px', right:'-20px', 'z-index':'100000' }, 'src':'bumpbox/closed.png', 'id':'closer' }) cl.addEvent('click',function(e){ e = new Event(e).stop(); bg.dispose(); $(el).getChildren().dispose(); eff2.start({ 'width':[maxw,1], 'height':[maxh,1], 'left': [endleft,middleH], 'top': [endtop, middleV+s] }) }) The IE error is just giving me line number 1 of the php, but the error, I'm sure, lays in the Javascript. Many thanks 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? |