JavaScript - Breaking Out Of Iframe By Ip Address
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> Similar TutorialsHi 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> <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. Hope I'm posting in the right section. At first I thought this was a CSS problem, but after careful exclusion of certain code in the CSS script, it looks to be a java issue...maybe. Here's the main page of the website I'm developing. Everything is running fine on he http://rutholsonphoto.com/test_build/index.php However this next page seems to be breaking my footer (the copyright and affiliation information). I have no idea how or why this is happening, but I'm hoping someone can go through my code and see what's up. http://rutholsonphoto.com/test_build/votenow-1.php Here's the included php script for the second page that SEEMS to be the culprit: Code: <script type="text/javascript"> /////////////////////////////////// function clickIE() {if (document.all) {(message);return false;}} function clickNS(e) {if (document.layers||(document.getElementById&&!document.all)) { if (e.which==2||e.which==3) {(message);return false;}}} if (document.layers) {document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;} else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;} document.oncontextmenu=new Function("return false") //////////////////////////////////// </script> <div id="maincontent"> <div id="titlebar"> <center><h3>2011 Senior Challenge Contestants</h3> </center> </div> <br /> <div id="subtitlebar"> <center> <strong>Senior Challenge Top 20:</strong> <a href="/voteresults.php">Click Here to View the Top 20!</a><br /> <br /> <div style="font-size:14px;">To build suspense we have removed the voting counters. Keep up the voting!</div> <div style="font-size:12px;">Only One Vote Per Household.</div><br /> </center> </div> <body class="section-1"> <ul id="menu"> <li><a href="./votenow-1.php"><u>A - F</u></a></li> <li><a href="./votenow-2.php"><u>G - L</u></a></li> <li><a href="./votenow-6.php"><u>M - R</u></a></li> <li><a href="./votenow-4.php"><u>S - X</u></a></li> <li><a href="./votenow-5.php"><u>Y - Z</u></a></li> </ul> </body> <div style="background-color:#d0d0d0" id="overlay"> <?php //FOR LETTER: A include("../templates/mysql_connect.php"); $query = "SELECT * FROM seniors WHERE last_name LIKE 'A%' ORDER BY last_name ASC"; $result = @mysql_query ($query); echo '<table width="480" height="150"><tr> <td width="161" valign="top" align="center"> <p><span class="style19"><u>-A-</u></span><br />'; while ($row = mysql_fetch_array ($result)){ echo "<a href=\"$row[pic_url]\" rel=\"lightbox[seniors]\" title=\" <form action ="/tallyvote.php?sen_id=$row[sen_id]" method="post"> $row[first_name] $row[last_name] - $row[school] <br /> <input name="submit" align="right" type="submit" value="Vote" > </form> \">$row[last_name], $row[first_name]</a><br/>"; } echo '</p>'; ?> <?php //FOR LETTER: B $query = "SELECT * FROM seniors WHERE last_name LIKE 'B%' ORDER BY last_name ASC"; $result = @mysql_query ($query); echo '<td width="161" valign="top" align="center"><p><span class="style19"><u>-B-</u></span><br />'; while ($row = mysql_fetch_array ($result)){ echo "<a href=\"$row[pic_url]\" rel=\"lightbox[seniors]\" title=\" <form action ="/tallyvote.php?sen_id=$row[sen_id]" method="post"> $row[first_name] $row[last_name] - $row[school] <input name="submit" type="submit" value="Vote" > </form> \">$row[last_name], $row[first_name]</a><br/>"; } echo '</p></td>'; ?> <?php //FOR LETTER: C $query = "SELECT * FROM seniors WHERE last_name LIKE 'C%' ORDER BY last_name ASC"; $result = @mysql_query ($query); echo '<td width="161" valign="top" align="center"><p><span class="style19"><u>-C-</u></span><br />'; while ($row = mysql_fetch_array ($result)){ echo "<a href=\"$row[pic_url]\" rel=\"lightbox[seniors]\" title=\" <form action ="/tallyvote.php?sen_id=$row[sen_id]" method="post"> $row[first_name] $row[last_name] - $row[school] <input name="submit" type="submit" value="Vote" > </form> \">$row[last_name], $row[first_name]</a><br/>"; } echo '</p></td></tr>'; ?> <?php //FOR LETTER: D $query = "SELECT * FROM seniors WHERE last_name LIKE 'D%' ORDER BY last_name ASC"; $result = @mysql_query ($query); echo '<tr><td width="161" valign="top" align="center"><p><span class="style19"><u>-D-</u></span><br />'; while ($row = mysql_fetch_array ($result)){ echo "<a href=\"$row[pic_url]\" rel=\"lightbox[seniors]\" title=\" <form action ="/tallyvote.php?sen_id=$row[sen_id]" method="post"> $row[first_name] $row[last_name] - $row[school] <input name="submit" type="submit" value="Vote" > </form> \">$row[last_name], $row[first_name]</a><br/>"; } echo '</p></td>'; ?> <?php //FOR LETTER: E $query = "SELECT * FROM seniors WHERE last_name LIKE 'E%' ORDER BY last_name ASC"; $result = @mysql_query ($query); echo '<td width="161" valign="top" align="center"><p><span class="style19"><u>-E-</u></span><br />'; while ($row = mysql_fetch_array ($result)){ echo "<a href=\"$row[pic_url]\" rel=\"lightbox[seniors]\" title=\" <form action ="/tallyvote.php?sen_id=$row[sen_id]" method="post"> $row[first_name] $row[last_name] - $row[school] <input name="submit" type="submit" value="Vote" > </form> \">$row[last_name], $row[first_name]</a><br/>"; } echo '</p></td>'; ?> <?php //FOR LETTER: F $query = "SELECT * FROM seniors WHERE last_name LIKE 'F%' ORDER BY last_name ASC"; $result = @mysql_query ($query); echo '<td width="161" valign="top" align="center"><p><span class="style19"><u>-F-</u></span><br />'; while ($row = mysql_fetch_array ($result)){ echo "<a href=\"$row[pic_url]\" rel=\"lightbox[seniors]\" title=\" <form action ="/tallyvote.php?sen_id=$row[sen_id]" method="post"> $row[first_name] $row[last_name] - $row[school] <input name="submit" type="submit" value="Vote" > </form> \">$row[last_name], $row[first_name]</a><br/>"; } echo '</p></td></tr>'; ?> </div> </div> Please Help. I so wanna get this part over with as it's killing me. I'm currently using the following code so that when I hover over my navigation images it fades them when hovered over. Code: <script type="text/javascript">$(function() {$(".fade-in").css("opacity","0");$(".fade-in").hover(function () {$(this).stop().animate({opacity: 1.0}, "220");},function () {$(this).stop().animate({opacity: 0}, "2000");});});</script> It works fine but when I have any other javascripts, such as a lightbox or image swapper, only one of them works. I want a lightbox script on the page so I need to figure out how to get both scripts working together. Note I'm not java developer, I just copied and pasted the code for my website so it's entirely possible, and probable, that I'm making a fundamental error here. It seems to be based on exactly where I add the jquery code. For example if I use the following code then the lightbox works but not the fader. Code: <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script> <script type="text/javascript" src="design/lightbox/prototype.js"></script> <script type="text/javascript" src="design/lightbox/scriptaculous.js?load=effects,builder"></script> <script type="text/javascript" src="design/lightbox/lightbox.js"></script> <script type='text/javascript'>$(function() {$(".fade-in").css("opacity","0");$(".fade-in").hover(function () {$(this).stop().animate({opacity: 1.0}, "220");},function () {$(this).stop().animate({opacity: 0}, "2000");});});</script> But if I use the following code then the lightbox doesn't work but the fader does. Code: <script type="text/javascript" src="design/lightbox/prototype.js"></script> <script type="text/javascript" src="design/lightbox/scriptaculous.js?load=effects,builder"></script> <script type="text/javascript" src="design/lightbox/lightbox.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script> <script type='text/javascript'>$(function() {$(".fade-in").css("opacity","0");$(".fade-in").hover(function () {$(this).stop().animate({opacity: 1.0}, "220");},function () {$(this).stop().animate({opacity: 0}, "2000");});});</script> Anybody know what's happening here? I am in desperate need for help as I'm pulling my hair out! I'm pretty sure this is JavaScript related. I'm incorporating a WordPress header into Opencart. Its pretty basic. I copied the WordPress header source code into the header of the Opencart and all is well in Firefox & Chrome and Safari. In IE however...If you enter the product page through the categories on the left the product page left aligns and breaks...I can't figure this out for the life of me. I tried to debug it with explorers tools but I don't know enough about Java script to understand why its breaking. Can anyone PLEASE help me on this?!!! My site is http://www.sterlingportable.com/store/ I have a strange problem. I'm running a shortcut with target: Code: "%PROGRAMFILES%\Internet Explorer\iexplore.exe" -k "C:\myfile.html" It opens the page in kiosk mode. The contents of myfile.html contains an image with an onclick to this function: Code: function loader(){ window.open('myurl.com','',''); } In Windows 7 32-bit running IE8 the url breaks out of kiosk mode. In Windows XP 64-bit running IE7 the url stays in kiosk mode. I can't think why. Is it the IE difference, the bit difference or the platform difference? Anyone struck this before? I know kiosk mode isn't that well used. I'm having a problem with links once I insert some javascript for a photo gallery into my page. I'm kind of new to all of this so sorry if this is something really easy, but I would like to make it so doesn't make my navigation links stop working, if possible. Code: $(function() { $(".image").click(function() { var image = $(this).attr("rel"); $('#image').hide(); $('#image').fadeIn('fast'); $('#image').html('<img src="' + image + '"/>'); return false; }); }); Hello! I come to you guys with a javascript problem. I'm using the javascript mouseover called wz_tooltip.js located here. Inside of it, I'm using many variables which have worked perfectly fine. If any variable has a value that conflicts with javascript, I simply do a php str_replace. This has worked perfectly for all but one issue. When one of the $string has a breaking line in it <br />, it breaks the javascript mouseover entirely. I can't figure this out for the life of me. The mouseover code itself is bolded: Code: $placeholders = array("'", "<br />"); $fixup = array("\'", "TEST"); $saPreview2 = str_replace($placeholders, $fixup, $lastxdevel2['pagetext']); $lastxdevelt2.="<div class='smallfont'><font size='2'><a onmouseover=\"Tip('<b>Title:</b> $saTitle2<br/><b>User:</b> $lastxdevel2[lastposter]<br /><b>Last Post:</b>$agdate2<br/><b>Preview: </b>$saPreview2')\" onmouseout=\"UnTip()\" href='showthread.php?t=$lastxdevel2[threadid]'>$lastxdevel2[title]</a></font></div>"; I tested with other values to make sure that the strings were properly being replaced, and indeed they were. I have the mouseover tooltip set to a specific width. So multiple lines work fine (one line running into another), but if there is a <br /> inside or any form of a formal line break, it literally causes the javascript mouseover script to cease to function. This is impossible to avoid because $string's value is text from a forum post. I'll reiterate that the str replace is working. When I view source, there are no <br/> tags. There are still line breaks though. Why would line breaks in $string cause a javascript mouseover to cease functioning? I have a feeling it must be how the tooltip handles line breaks? Thank you in advance. 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 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 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? 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. Hi, Not sure if I worded that question right. I have a web page which will display another web page in an iframe. But the content inside the iframe may change while the user interacts with it so I need to be able to resize the iframe height from code on the page inside the iframe. Any tips on how I can do that? I am using php and javascript. Thanks. hello everybody how can I set url in the address without opening the url , just placing ??? i.e : to open a url we use this PHP Code: document.location = 'http://www.codingforums.com/' I wanna show the user that the url is changing in the address bar as typing after it reached the end it will opens the url I don't care for the method of writing the new url in the address bar such as typing or sliding ... etc please tell me how to do this thanks I want to know how can i make javascript that i can use by run into in address bar.. I just need such javascript that run through address bar. My purpose is How can i check all check box in webpage that do not include all check or uncheck button? Best common example for check all or uncheck all is Quote: <html> <head> <title>Check All</title> <SCRIPT LANGUAGE="JavaScript"> function checkall(formid) { len=formid.ckb.length for(i=0;i<len;i++) { formid.elements.ckb[i].checked=true } } function uncheckall(formid) { len=formid.ckb.length for(i=0;i<len;i++) { formid.elements.ckb[i].checked=false } } </SCRIPT> </head> <body> <CENTER> <FORM NAME="myform"> <INPUT TYPE="checkbox" NAME="ckb"> Checkbox One <BR> <INPUT TYPE="checkbox" NAME="ckb"> Checkbox Two <BR> <INPUT TYPE="checkbox" NAME="ckb"> Checkbox Three <BR> <INPUT TYPE="button" NAME="chka" VALUE="Check All" onClick="checkall(this.form)"> <INPUT TYPE="button" NAME="unchka" VALUE="Uncheck All" onClick="uncheckall(this.form)"> </FORM> </CENTER> </body> </html> Now for above code If there would not have any javascript for select all then how can i use the select all javascript that i can run through address bar. i.e how can i just check all check box by using javascript? Hi guys! I have tried numerous attempts in getting the Address field to work (i.e. validated). I want it to accept letters, numbers, spaces and commas! However, it won't let me! Below is the code I have provided. Code: function validateAddress(fld) { var error = ""; var illegalChars = /[\W_]/; // } else if (illegalChars.test(fld.value)) { fld.style.background = 'Yellow'; error = "Your Billing address contains illegal characters!\n"; } else { fld.style.background = 'White'; } return error; } Thanks a lot! Ok, I'm nearly pulling my hair out with this one. I have been looking at this code for two evenings now, and rewrote it 4 times already. It started out as jQuery code and now it's just concatenating strings together. What I'm trying to do: Build a menu/outline using unordered lists from a multidimensional array. What is happening: Inside the buildMenuHTML function, if I call buildMenuHTML, the for loop only happens once (i.e. only for 'i' having a value of '0'.) If I comment out the call to itself, it goes through the for loop all 3 times, but obviously the submenus are not created. Here is the test object: Code: test = [ { "name" : "Menu 1", "url" : "menu1.html", "submenu" : [ { "name" : "menu 1 subitem 1", "url" : "menu1subitem1.html" }, { "name" : "menu 1 subitem 2", "url" : "menu1subitem2.html" } ] }, { "name" : "Menu 2", "url" : "menu2.html", "submenu" : [ { "name" : "menu 2subitem 1", "url" : "menu2subitem1.html" }, { "name" : "menu 2subitem 1", "url" : "menu2subitem1.html" } ] }, { "name" : "Menu 3", "url" : "menu3.html", "submenu" : [ { "name" : "menu 3 subitem 1", "url" : "menu3subitem1.html" }, { "name" : "menu 3 subitem 1", "url" : "menu3subitem1.html" } ] } ]; Here is the recursive function: Code: function buildMenuHTML(menuData,level) { var ul; if (level == 1) { ul = "<ul id='menu'>"; } else { ul = "<ul class='level" + level + "'>"; } for (i = 0; i < menuData.length; i++) { menuItemData = menuData[i]; ul += "<li>"; ul += "<a href='" + menuItemData.url + "'>" + menuItemData.name + "</a>"; if (typeof menuItemData.submenu != 'undefined') { ul += buildMenuHTML(menuItemData.submenu,level + 1); } ul += "</li>"; } ul += "</ul>"; return ul; } Here is how the function is called initially: Code: buildMenuHTML(test,1); This is it's return value (with indentation added for readability): Code: <ul id='menu'> <li><a href='menu1.html'>Menu 1</a> <ul class='level2'> <li><a href='menu1subitem1.html'>menu 1 subitem 1</a></li> <li><a href='menu1subitem2.html'>menu 1 subitem 2</a></li> </ul> </li> </ul> 'Menu 2' and 'Menu 3' don't show up! I'm sure it's something small that I'm overlooking, but any help would be appreciated. I have an iframe that is a specific height and width. I want to detect whenever the the iframe is no longer exactly the height i set it to. If a user has CSS turned off for example the iframe will be in default height and width. I want to detect that. This is how you'd normally do it but this only returns the original size (try with 'no style' in Firefox): Code: function getSize() { alert('height is now '+document.getElementById("Iframemain").height) alert('height is now '+document.getElementById("Iframemain").width) } Is it possible? Hello to all and thanks in advance for my help. I know this has been posted in different places on the web but I have found no solid solution. Here is my problem: I have an iframe the loads up a page on a remote server (out of my hands) and when I send certain information to it, the page redirects my entire site to their 404 page. I need to prevent this from happening so I engaged in much research and found this... temporary fix: Code: <script> // No redirection! var prevent_bust = 0 window.onbeforeunload = function() { prevent_bust++ } setInterval(function() { if (prevent_bust > 0) { prevent_bust -= 2 window.top.location = 'http://www.mysite.com/my404.html' } }, 1) </script> What this code does, is that every time the unload of a page happens, it will redirect me to my404.html and this does solve the problem of the iframe trying to redirect my entire site but anytime a user tried to go to a new website by typing it in the address bar, they are redirected to my404.html. Is there another solution for me so that the page within the iframe cannot redirect the parent page? Hello. Is the any chance to increment IP address in Javascript ? For example 11.12.13.14 plus 1 will be 11.12.13.15 I've started to modify my old script: Code: var ipa = 10.11.12.13; var partsa = []; var tempa = ipa; for ( var p = 0; p < 3; ++p ) { var dot1t = tempa.indexOf("."); partsa[p] = tempa.substring(0,dot1t); tempa = tempa.substring(dot1t+1); } partsa[3] = tempa; But do not know how to display ip like: ( parts1[0].parts1[1].parts1[2].parts1[3]+1 ) Please help. Leos |