• Как открывать ссылки внутри iframe в самом iframe?

    @anton_kuvyrkin
    Это общий код страницы (index.html) если что под правишь я просто экспериментирую.
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <head>
    <style type="text/css">
    html{overflow:hidden;}
    body{margin:0;padding:0;font-family:arial,sans-serif;font-size:16px;color:#6C8289;}a{color:#F9780E;text-decoration:none;}a:hover{color:#F9780E;text-decoration:none;}img{border:0;}#toolbar{background:#F9780E;height:53px;overflow:hidden;}#search{float:left;width:270px;margin:10px 0 0 15px;}#search a{color:#F9EAD4;font:bold 180% Oswald;font-weight:900;text-shadow:1px 1px 10px #FFFFFF;padding:5px 5px .15em;text-decoration:none;margin-left:auto;margin-right:auto;}#search a:hover{color:#111111;text-decoration:none;}#main{margin-left:15px;}#links{height:25px;}#close{width:16px;height:16px;margin:18px 0 0 0;position:absolute;right:5px;background:url(http://4.bp.blogspot.com/-S6Ba-AjQXBs/T0X4-ZcxyCI/AAAAAAAACqM/3j3ve6xWNFE/s1600/%255Bwww.gj37765.blogspot.com%255Dr.png) transparent no-repeat;}#arrow{position:absolute;right:30px;width:16px;height:16px;margin:18px 0 0 0;background:url(http://4.bp.blogspot.com/-S6Ba-AjQXBs/T0X4-ZcxyCI/AAAAAAAACqM/3j3ve6xWNFE/s1600/%255Bwww.gj37765.blogspot.com%255Dr.png) transparent no-repeat;background-position:-32px 0;}#back{background:#F9EAD4;width:523px;height:31px;position:absolute;margin:12px 0 0 0;padding-left:35px;padding-top:7px;left:280px;font-weight:bold;/*border-radius*/-webkit-border-radius:20px;-moz-border-radius:20px;border-radius:20px;}#twitter{width:90px;height:25px;margin:18px 0 0 0;position:absolute;right:100px;background:url(http://2.bp.blogspot.com/-ATU-s-QQTR0/T0X5c2GmweI/AAAAAAAACqU/PY0M_WC9qEo/s1600/%255Bwww.gj37765.blogspot.com%255Dretweet.png) transparent no-repeat;}#face{width:90px;height:25px;margin:18px 0 0 0;position:absolute;right:200px;}#extra{height:100px;margin:35px 0 0 0;}#iframe{overflow:hidden;}/*this is to remove the scroll when not needed*/#iframe, iframe{width:100%;height:100%;}</style>
    <script src="http://makingdifferent.github.com/blogger-widgets/[www.gj37765.blogspot.com]jquery-1.3.2.min.js" type="text/javascript" ></script>
     <title>Making Different Browser.</title>
    </head>
    
    <body onload="setFrame()">
    <script type="text/javascript" >
    $(document).ready(main);
    
    function main() {
        $('iframe').attr('src', getIframeUrl());
        registerEvents();
        resizeIframe()
    }
    
    function setFrame(){
        if(opener){
            var str=parent.location.href;
            var pos=str.indexOf("?")+1;
            var page=str.substring(pos);
            document.getElementById("fr").src=page;
        }
    }//-->
    
    function getIframeUrl() {
        var url = window.location.href;
        var iframe_url = ' ';
        var param_start = url.indexOf("iframe=");
        if (param_start != -1) iframe_url = url.substr(param_start + 7, url.length - param_start - 7);
        if (iframe_url.indexOf("http://") == -1) iframe_url = "http://" + iframe_url;
        return iframe_url
    }
    
    function registerEvents() {
        $(window).resize(function() {
            resizeIframe()
        });
        $("#back").bind("click", function() {
            window.history.back()
        });
        $("#arrow").bind("click", onArrow);
        $("#searchBtn").bind("click", onSearch);
        $("#close").bind("click", function() {
            window.location.href = $("iframe").attr("src")
        });
        $("#twitter").bind("click", function() {
            window.location.href = "http://twitter.com/?status=" + getIframeUrl() + " - "
        });
        $("#search").bind("keypress", function(e) {
            e = e || window.event;
            if (e.keyCode == 13) {
                onSearch()
            }
        })
    }
    var arrawState = "up";
    
    function onArrow() {
        if (arrawState == "up") onDownArrow();
        else onUpArrow()
    }
    
    function onDownArrow() {
        $("#toolbar").animate({
            height: 125
        }, 1000, "swing", function() {
            $("#arrow").css("background-position", "-32px 0");
            resizeIframe();
            arrawState = "down"
        })
    }
    
    function onUpArrow() {
        $("#toolbar").animate({
            height: 52
        }, 1000, "swing", function() {
            $("#arrow").css("background-position", "-16px 0");
            resizeIframe();
            arrawState = "up"
        })
    }
    
    function onSearch() {
        var qs = $("#qs").val();
        $('iframe').attr('src', 'http://www.google.com/search?q=' + qs)
    }
    
    function resizeIframe() {
        $("#iframe").height(WindowHeight() - getObjHeight(document.getElementById("toolbar")))
    }
    
    function WindowHeight() {
        var de = document.documentElement;
        return self.innerHeight || (de && de.clientHeight) || document.body.clientHeight
    }
    
    function getObjHeight(obj) {
        if (obj.offsetWidth) {
            return obj.offsetHeight
        }
        return obj.clientHeight
    }
    </script>
    
    
    <div id='toolbar'>
    <div id='search'>
    
    </div>
    <div id='main'>
    <div id='links'>
    <a id='arrow' href='javascript:void(0);'></a>
    <a id='close' href='javascript:void(0);'></a>
    </div>
    <div id='extra'>
    </div></div></div>
    
    <script language="JavaScript" type="text/javascript">
    function gonow(what){
         var selectedopt=what.options[what.selectedIndex]
         if (document.getElementById && selectedopt.getAttribute("target")=="fr"){
              window.open(selectedopt.value)
         }
         else{window.location=selectedopt.value}
    }</script>
    <form name="fr">
    <select name="fr">
    <option value="#">Выберите сайт...</option>
    <option value="https://wordstat.yandex.ua/" target="fr">Яndex</option>
    <option value="https://www.google.ru/trends/" target="fr">Google</option>
    <option value="http://webmaster.mail.ru/querystat" target="fr">Mail.ru</option>
    <option value="http://wordstat.rambler.ru/wrds/" target="fr">Rambler.ru</option>
    
    </select>
    </form>
    <a href="https://wordstat.yandex.ua/" target="fr">Яndex</a>
    <a href="https://www.google.ru/trends/" target="fr">Google</a>
    <a href="http://webmaster.mail.ru/querystat" target="fr">Mail.ru</a>
    <a href="http://wordstat.rambler.ru/wrds/" target="fr">Rambler.ru</a>
    
    <a href="http://www.moswar.ru/" target="fr" rel="external">1</a>  
    <a href="http://webmaster.mail.ru/querystat" target="fr">2</a><br/>
    
    <script type="text/javascript">
    $('a[rel=external]').attr('target','_blank');
    </script>
    <div id='iframe'>
    <iframe name="fr" id="fr" src="" frameborder="1" target='_blanc'></iframe>
    </div> 
    
    </body>
    </html>
    Ответ написан
    Комментировать