admin管理员组

文章数量:1425801

I got a little slider with a black background with

opacity: 0.6

This is an external index.html (with a CSS, JS and img folder).

I'd like to open that index.html when i hit a link on an external page. So the page is just covered with that black overlay and the slider.

Do I have to do this with an iframe, which fades in? So like:

$(document).ready(function () {
$('#mylink a').click(function(){
    var iframeSrc = $(this).attr('href');
    $('#myiFrame').fadeOut(1000,function(){
        $('#myiFrame iframe').attr('src',iframeSrc);
        $('#myiFrame').fadeIn(1000);
    });
    return false;
});
});

Or is there any easier solution? The little problem is that I have to be able to write the text in a HTML-editor only, because where I got that link to open the slider is in a CMS with a HTML-Editor.

I got a little slider with a black background with

opacity: 0.6

This is an external index.html (with a CSS, JS and img folder).

I'd like to open that index.html when i hit a link on an external page. So the page is just covered with that black overlay and the slider.

Do I have to do this with an iframe, which fades in? So like:

$(document).ready(function () {
$('#mylink a').click(function(){
    var iframeSrc = $(this).attr('href');
    $('#myiFrame').fadeOut(1000,function(){
        $('#myiFrame iframe').attr('src',iframeSrc);
        $('#myiFrame').fadeIn(1000);
    });
    return false;
});
});

Or is there any easier solution? The little problem is that I have to be able to write the text in a HTML-editor only, because where I got that link to open the slider is in a CMS with a HTML-Editor.

Share Improve this question asked Dec 22, 2016 at 13:01 Tobias GlausTobias Glaus 3,6583 gold badges22 silver badges41 bronze badges 2
  • You can use a Modal window. Your question is still unclear... Can you clarify? – Praveen Kumar Purushothaman Commented Dec 22, 2016 at 13:01
  • I want to open an external link as an overlay. So if I click a link on my page, I want that the page gets darker and for example google. appears over my page. More understandable now? – Tobias Glaus Commented Dec 22, 2016 at 13:04
Add a ment  | 

1 Answer 1

Reset to default 4

If I got u correctly-

function openNav() {
    document.getElementById("myNav").style.width = "100%";
}

function closeNav() {
    document.getElementById("myNav").style.width = "0%";
}
body {
    margin: 0;
    font-family: 'Lato', sans-serif;
}

.overlay {
    height: 100%;
    width: 0;
    position: fixed;
    z-index: 1;
    top: 0;
    left: 0;
    background-color: rgb(0,0,0);
    background-color: rgba(0,0,0, 0.9);
    overflow-x: hidden;
    transition: 0.5s;
}

.overlay-content {
    position: relative;
    top: 25%;
    width: 100%;
    text-align: center;
    margin-top: 30px;
}

.overlay a {
    padding: 8px;
    text-decoration: none;
    font-size: 36px;
    color: #818181;
    display: block;
    transition: 0.3s;
}

.overlay a:hover, .overlay a:focus {
    color: #f1f1f1;
}

.overlay .closebtn {
    position: absolute;
    top: 20px;
    right: 45px;
    font-size: 60px;
}

@media screen and (max-height: 450px) {
  .overlay a {font-size: 20px}
  .overlay .closebtn {
    font-size: 40px;
    top: 15px;
    right: 35px;
  }
}
<div id="myNav" class="overlay">
  <a href="javascript:void(0)" class="closebtn" onclick="closeNav()">&times;</a>
  <div class="overlay-content">
    <iframe src="http://www.w3schools./"></iframe>
  </div>
</div>


<span style="font-size:30px;cursor:pointer" onclick="openNav()">&#9776; open</span>

     

本文标签: javascriptOpen external link as an overlay on the same pageStack Overflow