Iframe FadeOut/FadeIn - javascript

I am trying to make an iframe fade out then fade in but I can't seem to get the code right. I think I am pretty close but for some reason the code acts as if my jquery isn't there. Can someone identify where I went wrong?
HTML
<body>
<center>
<div class="headbackground">
<h1 class="headfont1"> Kellen's Homepage</h1>
<div id="menubar">
<a id="menulink" href="homepage.html" target="iframe1"> Homepage </a>
<a id="menulink" href="about.html" target="iframe1"> About Me </a>
<a id="menulink" href="projects.html" target="iframe1"> Projects </a>
<a id="menulink" href="resume.html" target="iframe1"> Resume </a>
</div>
</div>
</center>
<div id="iframediv">
<iframe id="iframe1" name="iframe1" src="" frameborder="0"></iframe>
</div>
</body>
CSS
.headbackground {
background-color:RGBa(0,0,0,.75);
z-index:2;
margin-top:0;
}
div#menubar {
padding: 24px;
}
div#menubar > a {
font:"Trebuchet MS", Arial, Helvetica, sans-serif;
font-size:17px;
background:#333;
padding: 12px 24px;
color: #999;
margin-right: 10px;
text-decoration:none;
border-radius:3px;
transition: background 0.3s linear 0s, color 0.3s linear 0s;
}
div#menubar > a:hover {
background:#36F;
color:#FFF;
z-index:2;
}
#iframe1 {
position: absolute;
left: 0px;
top: 215px;
width: 100%;
height: 100%;
z-index:1;
}
body {
background-image:url(images/ronaldo-elche-real-madrid-live-bale-isco-best-team-celebrating-goal.jpg);
background-repeat:repeat-y;
background-position:top center;
background-attachment:fixed;
background-size:cover;
margin:0;
overflow:scroll;
}
jQuery
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
$(document).ready(function () {
$('div#menubar > a').click(function(){
var iframeSrc = $(this).attr('href');
$('#iframediv').fadeOut(1000,function(){
$('#iframediv iframe').attr('src',iframeSrc);
$('#iframediv').fadeIn(1000);
});
return false;
});
});
</script>

that's because to the browser, your code isn't there. Your code needs to be in a separate script tag.
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
$(document).ready(function () {
$('div#menubar > a').click(function(){
var iframeSrc = $(this).attr('href');
$('#iframediv').fadeOut(1000,function(){
$('#iframediv iframe').attr('src',iframeSrc);
$('#iframediv').fadeIn(1000);
});
return false;
});
});
</script>

Related

How to put a transitioning underline under div?

I am trying to make a container div get a blue underline when it is clicked.
I found a fiddle that I hoped would help me with this:
http://jsfiddle.net/gvpr9w06/
Although I can not make it work, my fiddle:
https://jsfiddle.net/gzp97yjo/
My code:
Html:
<div class="AdministrationSettingsArea">
<a href="#">
<div class="linkContainer tablik">
<div class="">Domains</div>
</div>
</a>
<a href="#">
<div class="linkContainer tablik">
<div class="">Something new</div>
</div>
</a>
<a href="#">
<div class="linkContainer tablik">
<div class="">Darkside</div>
</div>
</a>
</div>
Css:
.tablik {
display: inline-block;
cursor:pointer;
}
.AdministrationSettingsArea a .linkContainer{
display: inline-block;
float: left;
width:33%;
padding:5px 10px;
text-align:left
}
.AdministrationSettingsArea a .linkContainer:hover{
color:black;
background-color:#F1F1F1;
}
.tablik:after{
display: block;
height: 5px;
width: 0;
background: transparent;
transition: width .5s ease, background-color .5s ease;
}
.tablik.AdmClicked:after{
width: 100%;
background: blue;
}
Script:
$(function(){
$(".AdministrationSettingsArea a").on("click", function() {
console.log($(this).find(".tablik"));
if ($(this).find(".tablik").hasClass("AdmClicked")) return;
$(this).parent().find(".tablik").removeClass("AdmClicked");
$(this).find(".tablik").addClass("AdmClicked");
})
})
What am i missing?
You're missing from the original:
.tablik:after {
content: '';
so the :after has no content, so is not displayed.

How to make a cross close sign in popup

I have used a popup script so that popup appear on my screen when I load my html file now I want a close sign on the top right corner on the popup screen like in the picture shown below
The code I have used is
("jsfiddle.net/sGeVT/10/")
this script code is an example of my code I have further modified it but the basic of the popup is same.
Hope you understand and can give solution.
(1) Add a span with a x inside, × the best looking one IMO.
<span class="deleteMeetingClose">×</span>
(2) Set up some styles for it.
.deleteMeetingClose {
font-size: 1.5em;
cursor: pointer;
position: absolute;
right: 10px;
top: 5px;
}
(3) Add it to the jQuery code along with other close triggers.
$('#overlay, .deleteMeetingCancel, .deleteMeetingClose').click(function () {
//close action
});
Updated demo: http://jsfiddle.net/zj0yL9me/
$('.deleteMeeting').click(function () {
$('#overlay').fadeIn('slow');
$('#popupBox').fadeIn('slow');
$('#popupContent').fadeIn('slow');
});
// added .deleteMeetingClose into the selectors
$('#overlay, .deleteMeetingCancel, .deleteMeetingClose').click(function () {
$('#overlay').fadeOut('slow');
$('#popupBox').fadeOut('slow');
$('#popupContent').fadeOut('slow');
});
$('.deleteMeetingButton').click(function () {
$('#popupContent').fadeOut('slow');
$('#deleteMeetingConfirmDeleted').fadeIn('slow');
$('#overlay').delay(1300).fadeOut('slow');
$('#popupBox').delay(1300).fadeOut('slow');
$('#deleteMeetingConfirmDeleted').fadeOut('slow');
});
#overlay {
display:none;
opacity:0.5;
background-color:black;
position:fixed;
width:100%;
height:100%;
top:0px;
left:0px;
z-index: 999;
}
#popupBox {
display:none;
position: relative;
margin-left:auto;
margin-right:auto;
margin-top:100px;
width:600px;
height: 500px;
color: #000000;
border:5px solid #4E93A2;
-moz-border-radius:8px;
-webkit-border-radius:8px;
background-color:#FFFFFF;
z-index: 1000;
}
#popupContent {
display:none;
font-family:Arial, Helvetica, sans-serif;
color: #4E93A2;
margin-top:30px;
margin-left:30px;
margin-right:30px;
}
.deleteMeetingButton {
clear:both;
cursor:pointer;
width:90px;
height:30px;
border-radius: 4px;
background-color: #5CD2D2;
border:none;
text-align:center;
line-height:10px;
color:#FFFFFF;
font-size:11px;
font-family:Arial, Helvetica, sans-serif;
font-weight:bold;
}
.deleteMeetingCancel {
clear:both;
cursor:pointer;
width:90px;
height:30px;
border-radius: 4px;
background-color: #5CD2D2;
border:none;
text-align:center;
line-height:10px;
color:#FFFFFF;
font-size:11px;
font-family:Arial, Helvetica, sans-serif;
font-weight:bold;
content:"XXXX";
}
#deleteMeetingConfirmDeleted {
display:none;
}
/* added code below */
.deleteMeetingClose {
font-size: 1.5em;
cursor: pointer;
position: absolute;
right: 10px;
top: 5px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<div id="content">Content Obscured By Overlay
<button class="deleteMeeting">Delete</button>
</div>
<div id="overlay"></div>
<div id="popupBox">
<div id="popupContent">
<i>Are you sure you want to delete this meeting?</i>
<br />
<span style="text-align:center;color:black;font-size:40px;">YO</span>
<br />
<button class="deleteMeetingButton">Delete</button>
<button class="deleteMeetingCancel">Cancel</button>
</div>
<div id="deleteMeetingConfirmDeleted">Meeting Deleted</div>
<span class="deleteMeetingClose">×</span> <!-- <= added this line -->
</div>
First, put in image element in your popup div
<img id="ClosePopup" src="insert-image-url-here"/>
Then, style it with position:absolute. Also, make sure the popup div has position:relative
#ClosePopup{
position: absolute;
right:0px;
}
Finally, attach your click handler
$('#ClosePopup').click(function(){
$('#overlay,#popupBox,#popupContent').fadeOut('slow');
});
See it working in this fiddle
If you want a pure css solution without images, see
Pure css close button
Simply create a span element containing × char for the x, put some style and bind the click event to the popup close action:
HTML
<span class="cancel-icon" >×</span>
CSS:
.cancel-icon{
float:right;
cursor:pointer;
}
JS
$('.cancel-icon').click(function () {
//Close the popup
});
Using your Fiddle: http://jsfiddle.net/sGeVT/118/

dynamically loading content with jquery doesnt work

So..
I've been trying to dynamically load content but when I click on the menu loader shows only. It seems I can't figure this out, can you please look at the code and tell me if I missed something or did wrong?
this is my html
<body>
<div id="wrapper">
<div id="top">
<div id="logo">
<img src="images/logo.png"/>
</div>
<div id='cssmenu'>
<ul id="nav">
<li class='has-sub'>Storitve
<ul>
<li>Grafično oblikovanje</li>
<li>Spletno oblikovanje</li>
<li>Industrijsko oblikovanje</li>
</ul>
</li>
<li>Reference</li>
<li>Cenik</li>
<li class='last'>Kontakt</li>
</ul>
</div>
</div>
<div id="content">
</div>
<div id="footer">
<p>©Copyright 2015</p>
</div>
</div>
</body>
</html>
..and js
$(document).ready(function() {
var hash = window.location.hash.substr(1);
var href = $('#nav li a').each(function(){
var href = $(this).attr('href');
if(hash==href.substr(0,href.length-5)){
var toLoad = hash+'.html #content';
$('#content').load(toLoad)
}
});
$('#nav li a').click(function(){
var toLoad = $(this).attr('href')+' #content';
$('#content').hide('fast',loadContent);
$('#load').remove();
$('#wrapper').append('<span id="load">LOADING...</span>');
$('#load').fadeIn('normal');
window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-5);
function loadContent() {
$('#content').load(toLoad,'',showNewContent())
}
function showNewContent() {
$('#content').show('normal',hideLoader());
}
function hideLoader() {
$('#load').fadeOut('normal');
}
return false;
});
});
and css
body { width:100%;
height:100%;
margin:0px;
padding:0px;
font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, Sans-Serif;
text-align:center;
background:#BFBFBF;
padding-bottom:60px;
}
#logo { float:left;
position: fixed;
margin-top: 20px;
margin-left: 20px;
margin-bottom:20px;
z-index: 2000;
}
#top { position:relative;
top: 0px;
left:0px;
width:945px;
height: 160px;
background-color: white;
z-index:auto;
opacity: ;
}
#cssmenu { float:right;
position:fixed;
margin-top:123px;
margin-left:554px;
font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, Sans-Serif;
font-size: 11px;
line-height: 15px;
text-transform: uppercase;
text-align: left;
z-index:3;
}
#cssmenu > ul { width: auto;
list-style-type: none;
padding: 0;
margin: 0;
}
#centeredmenu ul ul {
z-index: 1 !Important;
}
#wrapper { width: 945px;
margin:0px auto;
background: #BBB;
position:relative;
border: ;
}
#content { width:880px;
background-color:white;
border: px solid white;
margin: 10px auto;
padding: 0 30px;
}
#footer { position:fixed;
bottom:0;
left:0;
width:100%;
height:40px; /* Height of the footer */
background:white;
}
#load {
display: none;
position: absolute;
right:460px;
top: 380px;
background: url(../images/ajax-loader.gif);
width: 43px;
height: 11px;
text-indent: -9999em;
}
You are removing your loader from the DOM:
$('#load').remove();
yet after that you try to fade it in while it does not exist:
$('#load').fadeIn('normal');
Replace the .remove() with a .hide() call to hide it, but not remove it from the DOM.
This is my navigation menu and what I'm trying to make is when I click on navigation, it dynamically loads the requested page into a content div with jQuery.
<div id='cssmenu'>
<ul id="nav">
<li>Domov</li>
<li class='has-sub'>Storitve
<ul>
<li>Grafično oblikovanje</li>
<li>Spletno oblikovanje</li>
<li>Industrijsko oblikovanje</li>
</ul>
</li>
<li>Reference</li>
<li>Cenik</li>
<li class='last'>Kontakt</li>
</ul>
</div>
</div>
<div id="content"></div>
And I changed JS code into:
$(document).ready(function() {
// initial
$("#content").load("content/index.html");
// handle menu click
$("ul#nav li a").click(function() {
var page = $(this).attr("href") ;
$("#content").load("content/" + page + ".html");
return false;
});
});
but it's working just on 2 menu buttons.

jquery colorbox isn't working with mootools v1.1

I wanna use colorbox for 'join us menu' but it isn't working.
and I also tried fancybox, and got a same result..
actually colorbox performed well until I add mootools v1.1 to my jsp code.
I dont know what is mootools v1.1. I just copy some source that from
some awesome website for
using scroll view effect(I dont know exactly what this effect's name) on my page
scroll view effect is working well. you can see that when you clicked 'append1,2,3'
sorry for my poor english skill.
here is my code
<%# page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Spring Builder : append your heart </title>
<link rel="stylesheet" href="colorbox.css" type="text/css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.0.js"></script>
<script type="text/javascript" src="colorbox.js"></script>
<script type="text/javascript" src="mootools.v1.1.js"></script>
<script type="text/javascript">
$(function(){
$('.joinus').colorbox({
});
});
</script>
<style type="text/css">
* {
margin: 0;
padding: 0;
}
body {
font-family: 'Times New Roman', serif;
}
li {
list-style: none;
}
a {
text-decoration: none;
}
img {
border: 0;
}
#main_header{
width:1280px;
padding-left: 10px;
line-height:60px;
background: #59DA50;
color:#FFFFFF;
}
#main_bar{
overflow: hidden;
background: #EAEAEA;
}
#main_bar>ul.main_bar_left{
overflow: hidden;
float: left;
}
#main_bar>ul.main_bar_right{
overflow: hidden;
float: right;
}
#main_bar>ul.main_bar_left>li{
float:left;
}
#main_bar>ul.main_bar_right>li{
float:left;
}
#main_bar a{
display: block;
padding: 5px 20px;
border-right: 1px solid #BDBDBD;
}
#main_bar a:HOVER{
background: #CEF279;
}
#main_bar input{
margin:5px;
width: 80px;
}
#main_footer{
width:1280px;
margin:0 auto;
margin-bottom: 10px;
background: #353535;
color: #FFFFFF;
text-align: center;
padding: 10px;
}
#main_content {
margin:0px;
overflow:hidden;
/*height:387px;
width:99,9%;*/
border:none;
position:relative;
}
#main_content_bg {
width:5000px;
height:600px;
background-image:url(http://placehold.it/5000x600);
background-position:top left;
background-repeat:no-repeat;
background-color:#E6E6E4;
position:relative;
}
.section_content {
width:990px;
height:380px;
position:absolute;
}
#section1 {
left:0px;
top:0px;
}
#section2 {
left:1570px;
top:0px;
}
#section3 {
left:2880px;
top:0px;
}
</style>
</head>
<body>
<header id="main_header">
<h1>Spring Builder</h1>
</header>
<nav id="main_bar">
<ul class="main_bar_left">
<li><a id="append1" href="#">append1</a></li>
<li><a id="append2" href="#">append2</a></li>
<li><a id="append3" href="#">append3</a></li>
</ul>
<ul class="main_bar_right">
<li><input type="text" value="id" id="id" name="id"/></li>
<li><input type="password" id="pw" name="pw"/></li>
<li>Login</li>
<li>Join us</li>
</ul>
</nav>
<div id="main_content">
<div id="main_content_bg">
<div id="section1" class="section_content">
<h1>section1</h1></div>
<div id="section2" class="section_content">
<h1>section2</h1></div>
<div id="section3" class="section_content">
<h1>section3</h1></div>
</div>
</div>
<footer id="main_footer">
</footer>
<script src="scrollstyle.js" type="text/javascript"></script>
</body>
</html>
It's probably happen a conflict between Mootools and jQuery because both libraries are using $ sign, try to convert $ to jQuery for your jQuery code:
jQuery(function(){
jQuery('.joinus').colorbox({
});
});
or wrap your code inside:
jQuery(function($) {
$('.joinus').colorbox({
});
});

dynamically changing text in div

Can someone please take a moment to look over this and let me know where I am going wrong in my code?
For some reason, the content div won't change when the buttons are clicked.
It's very simple, and right now I feel very confused for not being able to find my error.
CSS:
#wrapper {
margin: 0 auto;
width:100%;
max-height: 133px;
font-family:Arial, Helvetica, sans-serif;
font-size:14px;
line-height:1.5em;
}
#buttons {
width:340px;
float: left;
height: 133px;
margin: 10px 10px 0 0px;
border-right: 1px solid #666;
}
#button1 a {
outline: none;
text-indent: -5000px;
display:block;
width:146px;
height:105px;
background-image:url(images/sprite_v2.png);
background-position: -292px 0px;
background-repeat:no-repeat;
float:left;
margin-right:20px;
}
#button1 a:hover {
background-position: -292 -105px;
}
#button1 a:active {
background-position: -292 -210px;
}
#button2 a {
outline: none;
text-indent: -5000px;
display:block;
width:146px;
height:105px;
background-image:url(images/sprite_v2.png);
background-repeat:no-repeat;
background-position: -438px 0;
float:left;
}
#button2 a:hover {
background-position: -438px -105px;
}
#button2 a:active {
background-position: -438px -210px;
}
#content {
font-family: Arial, Helvetica, sans-serif;
float: left;
display:block;
}
a {
text-decoration:none;
}
ul {
overflow:hidden;
margin: 10px 0 0 8px;
padding:0;
}
li{
line-height:1.5em;
display:inline;
}
#content1 {
color:#953735;
}
#content2 {
color:#604a7b;
}
JavaScript:
$('button').bind('click', function() {
$('div#content').html($('div#content' + ($(this).index()+1)).html());
});
HTML:
<div id="wrapper">
<div id="button">
<div id="button1">
</div>
<div id="button2">
Reporting Administrator
</div>
</div>
<div id="content">
<div id="content1">
<ul>
<li>Stuff1</li><br />
<li>Stuff1</li><br />
<li>Stuff1</li>
</ul>
</div>
<div id="content2" style="display:none;">
<ul>
<li>Stuff2</li><br />
<li>Stuff2</li><br />
<li>Stuff2</li>
</ul>
</div>
</div>
</body>
</html>
The selector $('button') is the problem. You don't want to select a button - element but an element within the div #button, am I right?
So you should take $("#button a") as selector, if you want to append the event handler to all links within the #button element.
David Müller had it correct regarding the button selector being an issue.
The switching wasn't occurring with the event on the link because the index of the links will be 0 since both are only children. If the event is instead on the parent div, the switching works. Below is a jsfiddle and the code.
http://jsfiddle.net/VrKsh/2/
<div id="wrapper">
<div id="button">
<div id="button1">
Content1
</div>
<div id="button2">
Content2
</div>
</div>
<div id="content">
<div id="content1">
<ul>
<li>Stuff1</li><br />
<li>Stuff1</li><br />
<li>Stuff1</li>
</ul>
</div>
<div id="content2" style="display:none;">
<ul>
<li>Stuff2</li><br />
<li>Stuff2</li><br />
<li>Stuff2</li>
</ul>
</div>
</div>
<script type="text/javascript">
$('#button div').bind('click', function() {
$('div#content div:visible').hide();
$('div#content' + ($(this).index() + 1)).show();
});
</script>

Categories