TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,971
  • Latest: camgear
Stats
  • Total Posts: 196,075
  • Total Topics: 21,339
  • Online today: 182
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online

Floating Blocks!!!!

Started by akulion, September 23, 2006, 04:17:34 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

akulion

oh ok lemme give it a go and ill try and make it work in a floating block

see u soon - keep ur fingers crossed that it works 

xDeathList5x

hehe okay

i shuld say that its a scyscraper format: means that it should be a 120x600 block

thanks akulion

akulion

ok this wont work because of a clash between ' and "

how so?

notice in your javascript code it uses both " and ' now the problem arises that if I replace the " with ' the code stops working and same if i replace the ' with "

And this poses an error for PHP since we can either use:
echo " (in this case you cannot use " anywhere within the code being echoed out)
OR
echo ' (in which case you cant use ' anywhere)

and since the javascript above is using BOTH ' and " its causing a problem

but dont worry

I am gona try and isolate the script by including it from an external file next to see if it works or use an Iframe to get it to display

hang in there   

akulion

#43
phew finally got it working but in a VERY different manner - your users will be able to:
- CLOSE the advert
- MINIMIZE the advert
- MAXIMIZE the advert
- RELAUNCH the advert by clicking on the 'launch advert' link

The advert should be fixed in one spot...to change the spot try switching block places like left right or center

the dragging function was lost unfortunately! so u wont be able to drag the advert around - but no biggie

See the demo on http://goofy-goobers.com/forum

Once done lemme know so I can remove that block and put back the original demo

Instalation:
so now you have to do this:

Put all this code in a block: (create a SCRIPTBOX) not php!



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
#dwindow {
position:absolute;
background-color:#ebebeb;
left:0px;
top:0px;
display:none;
opacity:0;
}
#dwdrag {
z-index:10;
cursor:pointer;
background-color:navy;
text-align:right;
border-bottom:1px solid black;
}
#dwdrag img {
position:relative;
left:0;
top:0;
z-index:11;
}
#dwholder, #dwholder div {
height:100%;
background-color:transparent;
border-width:0;
cursor:auto;
z-index:0;
}
#dwholder div{
border:2px solid silver;
border-top-width:0;
border-left:1px solid black;
}
.lw {
cursor:pointer;
text-decoration:underline;
color:blue;
}
</style>
<!--[if lte IE 5.5]>
<style type="text/css">
#dwdrag, .lw {
cursor:hand;
}
</style>
<![endif]-->
<!--[if gte IE 5.5]>
<style type="text/css">
#dwindow {
filter:alpha(opacity=1);
}
</style>
<![endif]-->
<script>

//DHTML Window script- Copyright Dynamic Drive (http://www.dynamicdrive.com)
//For full source code, documentation, and terms of usage,
//Visit http://www.dynamicdrive.com/dynamicindex9/dhtmlwindow.htm
//Modified for persistence and to upgrade functionality in
//http://www.dynamicdrive.com/forums username:jscheuer1
//This notice must remain for legal use.

var persist=1;
var dragapproved=false;
var minrestore=0, maxrestore=0, dwloaded=0;
var initialwidth, initialheight, initialtop, initialleft;

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function drag_drop(e){
var dw=document.getElementById("dwindow"), dws=dw.style;
if (typeof e=='undefined'&&dragapproved&&event.button==1){
dws.left=Math.max(0, Math.min(iecompattest().clientWidth-dw.offsetWidth+iecompattest().scrollLeft, tempx+event.clientX-offsetx))+"px";
dws.top=Math.max(0, Math.min(iecompattest().clientHeight-dw.offsetHeight+iecompattest().scrollTop, tempy+event.clientY-offsety))+"px";
if(tempx+event.clientX-offsetx<0||tempy+event.clientY-offsety<0||iecompattest().clientHeight-dw.offsetHeight+iecompattest().scrollTop<tempy+event.clientY-offsety||iecompattest().clientWidth-dw.offsetWidth+iecompattest().scrollLeft<tempx+event.clientX-offsetx)
stopdrag();
}
else if (e&&dragapproved){
dws.left=Math.max(0, Math.min(window.innerWidth-dw.offsetWidth+window.pageXOffset, tempx+e.clientX-offsetx))+"px";
dws.top=Math.max(0, Math.min(window.innerHeight-dw.offsetHeight+window.pageYOffset, tempy+e.clientY-offsety))+"px";
if(window.innerWidth-dw.offsetWidth+window.pageXOffset<tempx+e.clientX-offsetx||window.innerHeight-dw.offsetHeight+window.pageYOffset<tempy+e.clientY-offsety||tempx+e.clientX-offsetx<0||tempy+e.clientY-offsety<0)
stopdrag();
return false;
}
}

function initializedrag(e){
var dw=document.getElementById("dwindow");
if (minrestore)
return;
offsetx=e.clientX;
offsety=e.clientY;
document.getElementById("dwindowcontent").style.display="none"; //extra
tempx=parseInt(dw.style.left);
tempy=parseInt(dw.style.top);

dragapproved=true;
document.onmousemove=function(e){return drag_drop(e);};
return false;
}

function loadwindow(url,width,height,resets){
if (!document.getElementById||!/number/.test(typeof window.pageYOffset+typeof iecompattest().scrollTop))
window.open(url,"","width=width,height=height,scrollbars=1")
else{
var dws=document.getElementById('dwindow').style;
if (resets)
eraseCookie('dwcookie');
if(typeof dwindow!='undefined'&&dwindow.filters&&!readCookie('dwcookie'))
dwindow.style.filter='alpha(opacity=100)';
else if (!readCookie('dwcookie'))
dws.opacity=1;
dws.display='block';
dws.width=initialwidth=width+"px";
dws.height=initialheight=height+"px";
dws.left="30px";
dws.top=typeof window.pageYOffset=='number'? window.pageYOffset*1+30+"px" : iecompattest().scrollTop*1+30+"px"
document.getElementById("cframe").src=url
if(!readCookie('dwcookie')&&!resets){
initialtop=dws.top;
initialleft=dws.left;
maxrestore=1;
minimize();
}
if(dwloaded){
minrestore=0;
setdwcookie();
}
dwloaded=1;
}
}

function maximize(){
var dws=document.getElementById("dwindow").style;
if (minrestore==0){
if (maxrestore)
minimize();
minrestore=1 //maximize window
document.getElementById("dwdrag").style.cursor='default';
initialtop=dws.top;
initialleft=dws.left;
document.getElementById("maxname").setAttribute("src","restore.gif")
dws.height=window.innerHeight? window.innerHeight-20+"px" : iecompattest().clientHeight+"px"
if (window.innerWidth)
var wp=window.innerHeight<iecompattest().offsetHeight? 20 : 0;
dws.width=window.innerWidth? window.innerWidth-wp+"px" : iecompattest().clientWidth+"px"
dws.left=typeof window.pageXOffset=='number'? window.pageXOffset+"px" : iecompattest().scrollLeft+"px"
dws.top=typeof window.pageYOffset=='number'? window.pageYOffset+"px" : iecompattest().scrollTop+"px"
}
else{
minrestore=0; //restore window
document.getElementById("dwdrag").style.cursor='';
document.getElementById("maxname").setAttribute("src","max.gif")
dws.width=initialwidth;
dws.height=initialheight;
dws.top=initialtop;
dws.left=initialleft;
}
setdwcookie();
}

function closeit(){
document.getElementById("dwindow").style.display='';
if(maxrestore)
minimize();
setdwcookie();
}

function stopdrag(){
if (minrestore)
return;
dragapproved=false;
document.onmousemove=null;
document.getElementById("dwindowcontent").style.display=''; //extra
setdwcookie();
}

function minimize(){
if(minrestore){
initialleft=(typeof window.pageXOffset=='number'? window.pageXOffset : iecompattest().scrollLeft)+(window.innerWidth? window.innerWidth : iecompattest().clientWidth)/2-parseInt(initialwidth)/2+'px';
initialtop=(typeof window.pageYOffset=='number'? window.pageYOffset : iecompattest().scrollTop)+"px";
maximize();
}
initialheight=maxrestore? initialheight : document.getElementById("dwindow").style.height;
document.getElementById("dwindow").style.backgroundColor=maxrestore? '#ebebeb' : 'transparent';
document.getElementById("minname").src=maxrestore? 'minus.gif' : 'plus.gif';
document.getElementById('dwholder').style.display=maxrestore? '' : 'none';
document.getElementById("dwindow").style.height=maxrestore? initialheight : 'auto';
maxrestore=maxrestore==0? 1 : 0;
setdwcookie();
}
function cb(){
document.getElementById("dwindow").style.backgroundColor='transparent';
return false;
}
function md(){
return false;
}

function setdwcookie(){
var dws=document.getElementById("dwindow").style;
initialtop=minrestore? initialtop : dws.top;
initialleft=minrestore? initialleft : dws.left;
var dwdisp=dws.display? dws.display : 'none';
createCookie('dwcookie',initialwidth+' '+initialheight+' '+initialleft+' '+initialtop+' '+minrestore+' '+maxrestore+' '+dwdisp, persist)
}

dwonload=function(){
if (readCookie('dwcookie'))
var cv=readCookie('dwcookie').split(' ')
else
return;
var dws=document.getElementById("dwindow").style;
initialleft=cv[2];
initialtop=cv[3]
dws.left=initialleft;
dws.top=initialtop;
if (cv[4]>0){
maximize();
initialwidth=cv[0];
initialheight=cv[1];
initialleft=cv[2];
initialtop=cv[3]
}
else if (cv[5]>0)
minimize();
dws.display=cv[6];
if(typeof dwindow!='undefined'&&dwindow.filters)
dwindow.style.filter='alpha(opacity=100)';
else
document.getElementById('dwindow').style.opacity=1;
dwloaded=1;
}

// http://www.quirksmode.org cookie unit:

function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}

function eraseCookie(name) {
createCookie(name,"",-1);
}

// End quirksmode.org cookie code

if ( typeof window.addEventListener != "undefined" )
    window.addEventListener( "load", dwonload, false );
else if ( typeof window.attachEvent != "undefined" )
    window.attachEvent( "onload", dwonload );
else {
    if ( window.onload != null ) {
        var oldOnload = window.onload;
        window.onload = function ( e ) {
            oldOnload( e );
            dwonload();
        };
    }
    else
        window.onload = dwonload;
}
</script>
</head>
<body>
<div id="dwindow" onmouseup="stopdrag();">
<div id="dwdrag" onmousedown="return initializedrag(event);" onmouseup="stopdrag();" onselectstart="return false;"><img src="minus.gif" id="minname" onmousedown="cb();" onclick="minimize();"><img src="max.gif" id="maxname" onmousedown="md();" onclick="maximize();"><img src="close.gif" onmousedown="md();" onclick="closeit();"></div>
<div id="dwholder"><div id="dwindowcontent">

<iframe id="cframe" src="about:blank" width=100% height=100% frameborder="0"></iframe>
</div></div>
</div>

<script>
//Use below code to load DHTML Window as page loads
loadwindow('advert_dsinclude.html',140,620);
</script>

<!--Use below code to load DHTML window via link-->
<span class="lw" onclick="loadwindow('advert_dsinclude.html',140,620,'r');">Launch Advert</a>
</body>



And then upload THIS FILE to your forum root (to download simply save the whole file or right click and "save as"

akulion

oh yea i forgot to mention - this script is much better since it will REMEMBER if your user closed the advert or not

so it wont keep poping back up for the same user unless they click "launch advert link"

akulion

oohh man where is my mind today!!

u will also need to upload these 4 images to ur forum root along with that file:






or u can use ur own lil images but name them the same as the images above and try and make them about the same size

xDeathList5x


akulion

oki doki

just remember that everytime u wana change the "advert block type" like size wise

go right to the bottom of the code I gave you and change the 2 numbers in each tag:



//Use below code to load DHTML Window as page loads
loadwindow('advert_dsinclude.html',140,620);
</script>

<!--Use below code to load DHTML window via link-->
<span class="lw" onclick="loadwindow('advert_dsinclude.html',140,620,'r');">Launch Advert</a>
</body>



PS: just out of curiosity - ur gona use it or is it too tacky?


xDeathList5x

mmh, is it possible to let my users only close the ad after they clicked it?

maybe it closes automatically after a click?

xDeathList5x

if this is possible i will use this script, cause upload videos all the time and spent a lot of time for the upload, my users can help me out gettin a better server

This website is proudly hosted on Crocweb Cloud Website Hosting.