Jump to content

Recommended Posts

Not sure if this is in the right section but was wondering if anyone can help me

 

I have the following code that is for my tumblr site 

tattoofreak87.tumblr.com

 

what i am aiming for is that when you click on the "ask me anything" link it will pop up the "ask me anything" box in the top center of the screen however not sure what i am doing wrong. as it stands right now the box is always there i there in the center and i would like it not to be. 

 

any help will be greatly appreciated

<html>

    <title>Vince's Tumblr</title>
    
    <head>
    <script type="text/javascript" 
src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script> 
<script> 
$(document).ready(function() { 
// 
$('a.poplight[href^=#]').click(function() { 
var popID = $(this).attr('rel'); //Get Popup Name 
var popURL = $(this).attr('href'); //Get Popup href to define size 
var query= popURL.split('?'); 
var dim= query[1].split('&'); 
var popWidth = dim[0].split('=')[1]; //Gets the first query string value 
$('#' + popID).fadeIn().css({ 'width': Number( popWidth ) }).prepend('<a href="#" class="close"><img src="http://png.findicons.com/files/icons/1714/dropline_neu/24/dialog_close.png" class="btn_close" title="Close" alt="Close" /></a>'); 
var popMargTop = ($('#' + popID).height() + 80) / 2; 
var popMargLeft = ($('#' + popID).width() + 80) / 2; 
//Apply Margin to Popup 
$('#' + popID).css({ 
'margin-top' : -popMargTop,
'margin-left' : -popMargleft 
}); 
$('body').append('<div id="fade"></div>');
$('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn(); //Fade in the fade layer - .css({'filter' : 'alpha(opacity=80)'}) 
return false; 
}); 
$('a.close, #fade').live('click', function() { 
$('#fade , .popup_block').fadeOut(function() { 
$('#fade, a.close').remove(); //fade them both out 
}); 
return false; 
}); 
}); 
    .popup_block{
display: none;
background: #D3D3D3;
background-image: url();
padding: 10px;
font-family: Garamond;
float: left;
font-size: 10px;
position: fixed;
top: 50%; left: 50%;
z-index: 2;
border: 2px solid #363636;
-moz-box-shadow: 0 0 5px #CFCFCF;
-webkit-box-shadow: 0 0 5px #CFCFCF;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
}
img.btn_close {
float: right;
margin: -5px -5px 0 0;
}
*html .popup_block {
position: absolute;
}
</script>

    </head>

    <body>
    
    <img src="https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash4/419067_238953752859147_1698306198_n.jpg" width="200" height="300">
    
    <div style="text/javascript">
    <li><a href="https://twitter.com/tattoofreak1987" Target="_blank">Twitter</a>
    <li><a href="https://www.facebook.com/tattoofreak1987">Facebook</a>
    <li><a href="#?w=500" rel="02" class="poplight">Ask Me Anything</a>
    </div>


    </body>
    
    <div id="02" class="popup_block">

<Center><font size="5" color="#1C1C1C"><p></font><iframe frameborder="0" scrolling="yes" width="50%" height="140" src="http://www.tumblr.com/ask_form/tattoofreak87.tumblr.com" style="background-color:transparent; overflow:hidden;" id="ask_form">
</center></div>

</div></div></div></div></div></div></div></div></div></div>

</html>

Sorry for the confusion,probably I misunderstood.

Put the CSS code between <style></style> tags and make sure they're between the head tags and aren't in <script> tags.

Also,you put the end of the body too early,put it before </html> so the "popup_block" will apear when you click.

Edited by KubeR

Okay I have updated my code to what I believe you are referencing to 

<html>

    <title>Vince's Tumblr</title>
    
    <head>
    
    <style type="text/css">
    
    }); 
    .popup_block{
display: none;
background: #D3D3D3;
background-image: url();
padding: 10px;
font-family: Garamond;
float: left;
font-size: 10px;
position: fixed;
top: 50%; left: 50%;
z-index: 2;
border: 2px solid #363636;
-moz-box-shadow: 0 0 5px #CFCFCF;
-webkit-box-shadow: 0 0 5px #CFCFCF;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
}
img.btn_close {
float: right;
margin: -5px -5px 0 0;
}
*html .popup_block {
position: absolute;
    }
    
    </style>

    </head>
    
    <body>
    
    <script type="text/javascript" 
src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script> 
<script> 
$(document).ready(function() { 
// 
$('a.poplight[href^=#]').click(function() { 
var popID = $(this).attr('rel'); //Get Popup Name 
var popURL = $(this).attr('href'); //Get Popup href to define size 
var query= popURL.split('?'); 
var dim= query[1].split('&'); 
var popWidth = dim[0].split('=')[1]; //Gets the first query string value 
$('#' + popID).fadeIn().css({ 'width': Number( popWidth ) }).prepend('<a href="#" class="close"><img src="http://png.findicons.com/files/icons/1714/dropline_neu/24/dialog_close.png" class="btn_close" title="Close" alt="Close" /></a>'); 
var popMargTop = ($('#' + popID).height() + 80) / 2; 
var popMargLeft = ($('#' + popID).width() + 80) / 2; 
//Apply Margin to Popup 
$('#' + popID).css({ 
'margin-top' : -popMargTop,
'margin-left' : -popMargleft 
}); 
$('body').append('<div id="fade"></div>');
$('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn(); //Fade in the fade layer - .css({'filter' : 'alpha(opacity=80)'}) 
return false; 
}); 
$('a.close, #fade').live('click', function() { 
$('#fade , .popup_block').fadeOut(function() { 
$('#fade, a.close').remove(); //fade them both out 
}); 
return false; 
}); 
</script>

    
    <img src="https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash4/419067_238953752859147_1698306198_n.jpg" width="200" height="300">
    
    <div style="text/javascript">
    <li><a href="https://twitter.com/tattoofreak1987" Target="_blank">Twitter</a>
    <li><a href="https://www.facebook.com/tattoofreak1987">Facebook</a>
    <li><a href="#?w=500" rel="02" class="poplight">Ask Me Anything</a>
    </div>

    
    <div id="02" class="popup_block">
<Center><font size="5" color="#1C1C1C"><p></font><iframe frameborder="0" scrolling="yes" width="50%" height="140" src="http://www.tumblr.com/ask_form/tattoofreak87.tumblr.com" style="background-color:transparent; overflow:hidden;" id="ask_form">
</center></div>

</div></div></div></div></div></div></div></div></div></div>
    
        
    </body>
</html>

Okay Played around with it again, and now the ask box is gone and no longer in the center of the screen, however now when I click on "Ask Me Anything" nothing is popping up.

<html>

    <title>Vince's Tumblr</title>
    
    <head>
    
    <style type="text/css">
    .popup_block{
display: none;
background: #D3D3D3;
background-image: url();
padding: 10px;
font-family: Garamond;
float: left;
font-size: 10px;
position: fixed;
top: 50%; left: 50%;
z-index: 2;
border: 2px solid #363636;
-moz-box-shadow: 0 0 5px #CFCFCF;
-webkit-box-shadow: 0 0 5px #CFCFCF;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
}
img.btn_close {
float: right;
margin: -5px -5px 0 0;
}
*html .popup_block {
position: absolute;
    }
    
    </style>

    </head>
    
    <body>
    
    <body background="http://www.wallpaper4me.com/images/wallpapers/gothicroses-7024.jpeg">
    
    <script type="text/javascript" 
src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script> 
<script> 
$(document).ready(function() { 
// 
$('a.poplight[href^=#]').click(function() { 
var popID = $(this).attr('rel'); //Get Popup Name 
var popURL = $(this).attr('href'); //Get Popup href to define size 
var query= popURL.split('?'); 
var dim= query[1].split('&'); 
var popWidth = dim[0].split('=')[1]; //Gets the first query string value 
$('#' + popID).fadeIn().css({ 'width': Number( popWidth ) }).prepend('<a href="#" class="close"><img src="http://png.findicons.com/files/icons/1714/dropline_neu/24/dialog_close.png" class="btn_close" title="Close" alt="Close" /></a>'); 
var popMargTop = ($('#' + popID).height() + 80) / 2; 
var popMargLeft = ($('#' + popID).width() + 80) / 2; 
//Apply Margin to Popup 
$('#' + popID).css({ 
'margin-top' : -popMargTop,
'margin-left' : -popMargleft 
}); 
$('body').append('<div id="fade"></div>');
$('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn(); //Fade in the fade layer - .css({'filter' : 'alpha(opacity=80)'}) 
return false; 
}); 
$('a.close, #fade').live('click', function() { 
$('#fade , .popup_block').fadeOut(function() { 
$('#fade, a.close').remove(); //fade them both out 
}); 
return false; 
}); 
</script>

    
    <img src="https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash4/419067_238953752859147_1698306198_n.jpg" width="200" height="300">
    
    <div style="text/javascript">
    <li><a href="https://twitter.com/tattoofreak1987" Target="_blank">Twitter</a>
    <li><a href="https://www.facebook.com/tattoofreak1987">Facebook</a>
    <li><a href="#?w=500" rel="02" class="poplight">Ask Me Anything</a>
    </div>
    
    <div id="02" class="popup_block">
<Center><font size="5" color="#1C1C1C"><p></font><iframe frameborder="0" scrolling="yes" width="50%" height="140" src="http://www.tumblr.com/ask_form/tattoofreak87.tumblr.com" style="background-color:transparent; overflow:hidden;" id="ask_form">
</center></div>

</div></div></div></div></div></div></div></div></div></div>
    
        
   </body>
</html>

Okay I got everything working I believe, now when you click on ask me anything it opens in same tab but it brings up the area to ask, however i want it to be a small pop up window that opens in the same page in the center of the screen or top center

 

http://tattoofreak87.tumblr.com

<html>
    <head>   

    <title>Vince's Tumblr</title>
    
    <style type="text/css">

    .popup_block{
display: none;
background: #D3D3D3;
background-image: url();
padding: 10px;
font-family: Garamond;
float: left;
font-size: 10px;
position: fixed;
top: 50%; left: 50%;
z-index: 2;
border: 2px solid #363636;
-moz-box-shadow: 0 0 5px #CFCFCF;
-webkit-box-shadow: 0 0 5px #CFCFCF;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
}
img.btn_close {
float: right;
margin: -5px -5px 0 0;
}
*html .popup_block{
position: absolute;
};
    
    </style>

    </head>
    
    <script type="text/javascript" 
src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js">
$(document).ready(function() { 
// 
$('a.poplight[href^=#]').click(function() { 
var popID = $(this).attr('rel'); //Get Popup Name 
var popURL = $(this).attr('href'); //Get Popup href to define size 
var query= popURL.split('?'); 
var dim= query[1].split('&'); 
var popWidth = dim[0].split('=')[1]; //Gets the first query string value 
$('#' + popID).fadeIn().css({ 'width': Number( popWidth ) }).prepend('<a href="#" class="close"><img src="http://png.findicons.com/files/icons/1714/dropline_neu/24/dialog_close.png" class="btn_close" title="Close" alt="Close" /> 
var popMargTop = ($('#' + popID).height() + 80) / 2; 
var popMargLeft = ($('#' + popID).width() + 80) / 2; 
//Apply Margin to Popup 
$('#' + popID).css({ 
'margin-top' : -popMargTop,
'margin-left' : -popMargleft 
}); 
$('body').append('<div id="fade">
$('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn(); //Fade in the fade layer - .css({'filter' : 'alpha(opacity=80)'}) 
return false; 
}); 
$('a.close, #fade').live('click', function() { 
$('#fade , .popup_block').fadeOut(function() { 
$('#fade, a.close').remove(); //fade them both out 
}); 
return false; 
}); 
</script>

    <body background="http://www.wallpaper4me.com/images/wallpapers/gothicroses-7024.jpeg">
    
    <img src="https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash4/419067_238953752859147_1698306198_n.jpg" alt ="pic" width="200" height="300">
    <br>
    <ul>
    <li><a href="https://twitter.com/Tat_Addict69" Target="_blank">Twitter</a>
    <li><a href="https://www.facebook.com/tattoofreak1987">Facebook</a>
    <li><a href="http://www.tumblr.com/ask_form/tattoofreak87.tumblr.com" rel="02" class="poplight">Ask Me Anything</a>
    </ul>
    
    <div id="02" class="popup_block" align="center">
<font size="5" color="#1C1C1C"><br></font><iframe frameborder="0" scrolling="yes" width="50%" height="140" src="http://www.tumblr.com/ask_form/tattoofreak87.tumblr.com" style="background-color:transparent; overflow:hidden;" id="ask_form">
    
    </body>        
</html>

<li><a href="http://www.tumblr.com/ask_form/tattoofreak87.tumblr.com" rel="02" class="poplight">Ask Me Anything</a></li>

You're redirecting to that page from here.

Change between the quoatation marks to #?w=400

as your jQuery is resizing the window by the width/number you write in the address bar after the #?w=

Edited by KubeR

When I change the href link to anything other then what is there right now the link won't work ? i updated it on my end however

Probably because you're redirecting it to the same page,where it gets the width size of the page and gives the poplight it's side,but it's just a guess.

Did you try what I said before ? (replacing it with ' #?w=400 ')

Edited by KubeR

Yes I have the only thing it will do is change the url to this "http://tattoofreak87.tumblr.com/#?w=400"

<html>
    <head>   

    <title>Vince's Tumblr</title>
    
    <style type="text/css">   
    
    .popup_block{
width:400px;
height:200px;
display: none;
background: #D3D3D3;
background-image: url();
padding: 10px;
font-family: Garamond;
float: left;
font-size: 10px;
position: fixed;
top: 50%; left: 50%;
z-index: 2;
border: 2px solid #363636;
-moz-box-shadow: 0 0 5px #CFCFCF;
-webkit-box-shadow: 0 0 5px #CFCFCF;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
}
img.btn_close {
float: right;
margin: -5px -5px 0 0;
}
*html .popup_block{
position: absolute;
}
    
    </style>

    </head>
    
    <script type="text/javascript" 
src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js">
$(document).ready(function() { 
// 
$('a.poplight[href^=#]').click(function() { 
var popID = $(this).attr('rel'); //Get Popup Name 
var popURL = $(this).attr('href'); //Get Popup href to define size 
var query= popURL.split('?'); 
var dim= query[1].split('&'); 
var popWidth = dim[0].split('=')[1]; //Gets the first query string value 
$('#' + popID).fadeIn().css({ 'width': Number( popWidth ) }).prepend('<a href="#" class="close"><img src="http://png.findicons.com/files/icons/1714/dropline_neu/24/dialog_close.png" class="btn_close" title="Close" alt="Close" /> 
var popMargTop = ($('#' + popID).height() + 80) / 2; 
var popMargLeft = ($('#' + popID).width() + 80) / 2; 
//Apply Margin to Popup 
$('#' + popID).css({ 
'margin-top' : -popMargTop,
'margin-left' : -popMargleft 
}); 
$('body').append('<div id="fade">
$('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn(); //Fade in the fade layer - .css({'filter' : 'alpha(opacity=80)'}) 
return false; 
}); 
$('a.close, #fade').live('click', function() { 
$('#fade , .popup_block').fadeOut(function() { 
$('#fade, a.close').remove(); //fade them both out 
}); 
return false; 
}); 
</script>

    <body background="http://www.wallpaper4me.com/images/wallpapers/gothicroses-7024.jpeg">
    
    <img src="https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash4/419067_238953752859147_1698306198_n.jpg" alt ="pic" width="200" height="300">
    <br>
    <ul>
    <li><a href="https://twitter.com/Tat_Addict69" Target="_blank">Twitter</a>
    <li><a href="https://www.facebook.com/tattoofreak1987">Facebook</a>
    <li><a href="#?w=400" rel="02" class="poplight">Ask Me Anything</a>
    </ul>
    
    <div id="02" class="popup_block" align="center">
<font size="5" color="#1C1C1C"><br></font><iframe frameborder="0" scrolling="yes" width="50%" height="140" src="http://www.tumblr.com/ask_form/tattoofreak87.tumblr.com" style="background-color:transparent; overflow:hidden;" id="ask_form">
    
    </body>        
</html>

Edited by spudly1987

$('#' + popID).fadeIn().css({ 'width': Number( popWidth ) }).prepend('<a href="#" class="close"><img src="http://png.findicons.com/files/icons/1714/dropline_neu/24/dialog_close.png" class="btn_close" title="Close" alt="Close" />
You forgot to close it

$('body').append('<div id="fade">
and this as well.

Also,you didn't close the .ready() event. ( }); at the end)

$('#' + popID).fadeIn().css({ 'width': Number( popWidth ) }).prepend('<a href="#" class="close"><img src="http://png.findicons.com/files/icons/1714/dropline_neu/24/dialog_close.png" class="btn_close" title="Close" alt="Close" /> ');
$('body').append('<div id="fade"> ');

Are these ^ now closed properly? 

In some case's HTML closes the tag by himself(As far as I know,but not sure if always or in which cases or even how),but just to make sure -

$('#' + popID).fadeIn().css({ 'width': Number( popWidth ) }).prepend('<a href="#" class="close"><img src="http://png.findicons.com/files/icons/1714/dropline_neu/24/dialog_close.png" class="btn_close" title="Close" alt="Close" /></a>');
$('body').append('<div id="fade"></div>');

Now only left is to close the .ready event.

Just add a }); at the end of the jQuery code(before </script>)

Edited by KubeR

Well,as you decide.

Anyhow,the last two steps are to close the first <script> tag & open it (because it should be seperated) and change the 'display' in CSS from "hide" to "block" when the user clicks.

I didn't hurry,because I thought I would confuse you and so you'll understand what you're doing and not just simply give you the working code,because there is no point in it.

So,the code should look like this :

<html>
    <head>
    <title>Vince's Tumblr</title>
    <style type="text/css">   
    .popup_block {
		width:400px;
		height:200px;
		display: none;
		background: #D3D3D3;
		background-image: url();
		padding: 10px;
		font-family: Garamond;
		float: left;
		font-size: 10px;
		position: fixed;
		top: 50%; left: 50%;
		z-index: 2;
		border: 2px solid #363636;
		-moz-box-shadow: 0 0 5px #CFCFCF;
		-webkit-box-shadow: 0 0 5px #CFCFCF;
		-webkit-border-radius: 10px;
		-moz-border-radius: 10px;
		border-radius: 10px;
	}
	.btn_close {
		float: right;
		margin: -5px -5px 0 0;
	}
	*html .popup_block{
		position: absolute;
	}
    </style>
    </head>
    <script language="JavaScript" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
	<script>
		$(document).ready(function() {  
			$('a.poplight[href^=#]').click(function() { 
				var popID = $(this).attr('rel'); //Get Popup Name 
				var popURL = $(this).attr('href'); //Get Popup href to define size 
				var query= popURL.split('?'); 
				var dim= query[1].split('&'); 
				var popWidth = dim[0].split('=')[1]; //Gets the first query string value 
				$('#' + popID).fadeIn().css({ 'width': Number( popWidth ) }).prepend('<a href="#" class="close"><img src="http://png.findicons.com/files/icons/1714/dropline_neu/24/dialog_close.png" class="btn_close" title="Close" alt="Close" /></a>');
				var popMargTop = ($('#' + popID).height() + 80) / 2; 
				var popMargLeft = ($('#' + popID).width() + 80) / 2; 
				//Apply Margin to Popup 
				$('#' + popID).css({ 
					'margin-top' : -popMargTop,
					'margin-left' : -popMargleft 
				}); 
				$('body').append('<div id="fade"></div>');
				$('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn(); //Fade in the fade layer - .css({'filter' : 'alpha(opacity=80)'}) 
				$(".poplight").css("display","block");
				return false; 
			}); 
			$('a.close, #fade').live('click', function() { 
				$('#fade , .popup_block').fadeOut(function() { 
					$('#fade, a.close').remove(); //fade them both out 
				}); 
				return false; 
			}); 
		});
	</script>
    <body background="http://www.wallpaper4me.com/images/wallpapers/gothicroses-7024.jpeg">
    <img src="https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash4/419067_238953752859147_1698306198_n.jpg" alt ="pic" width="200" height="300"><br>
    <ul>
    <li><a href="https://twitter.com/Tat_Addict69" Target="_blank">Twitter</a></li>
    <li><a href="https://www.facebook.com/tattoofreak1987">Facebook</a></li>
    <li><a href="#?w=400" rel="02" class="poplight">Ask Me Anything</a></li>
    </ul>
    <div id="02" class="popup_block" align="center">
<font size="5" color="#1C1C1C"><br></font><iframe frameborder="0" scrolling="yes" width="50%" height="140" src="http://www.tumblr.com/ask_form/tattoofreak87.tumblr.com" style="background-color:transparent; overflow:hidden;" id="ask_form">
    </body>        
</html>
Edited by KubeR

I appreciate you taking the time to do that, and it does work, just got two more questions if you don't mind, is there any way i can relocate the pop up to the top center of the screen? and how to i make the ask box fit inside the shadow

Edited by spudly1987
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.