/    Sign up×
Community /Pin to ProfileBookmark

Stumped by a div not displaying correctly with Safari

I’m having problems with a scroll element when using Safari (on Mac and PC). FF and IE show the following page correctly:

[url]http://www.lupadigitalpanama.com/print/example1.html[/url]

At the bottom of the page a ‘NEWER POSTS’ and ‘OLD POSTS’ should be viewable but they don’t show up using Safari (I am using version 4.0.3 on a PC for testing but its not working on Macs either). I’ve been at this for about half a day and have had no luck so I’m not sure if its a javascript issue or a CSS issue, but I welcome any bit of advice. IN any event if the ‘NEWER POSTS’ and ‘OLD POSTS’ are viewable they are suppose to slide the center page elements up or down. I think the slide part is working but if I was only able to figure out how they could be viewable with Safari I think I will have it working 100%. Your help is appreciated.

my CSS code for the element in question is:

#content2 .main2 .maininfo .outer_gallery .gallists #gallerypages {

background-image:url(‘../common/fotos/bg_bif’);
background-repeat:repeat-x;
text-align:right;
height:20px;
width: 592px;
margin-left: 1px;
visibility: visible;
padding: 0px;

}

#content2 .main2 .maininfo .outer_gallery .gallists #gallerypages a {
display:block;
height:20px;
border-left:1px solid #1a1a1a;
float:right;
font-size:11px;
font-weight:bold;
padding:0px 10px;
color:#C03;
background-repeat:no-repeat;
line-height:20px; line-height:18px;
text-decoration:none;
}

#content2 .main2 .maininfo .outer_gallery .gallists #gallerypages .newer {
background-image:url(‘../common/fotos/arrow_left_on.gif’); background-position:left center;
padding-left:15px;
}

#content2 .main2 .maininfo .outer_gallery .gallists #gallerypages .older {
background-image:url(‘../common/fotos/arrow_right_on.gif’); background-position:right center;
padding-right:15px;
}

#content2 .main2 .maininfo .outer_gallery .gallists #gallerypages .newerOff { background-image:url(‘../common/fotos/arrow_left_off.gif’); color:#C03;
}

#content2 .main2 .maininfo .outer_gallery .gallists #gallerypages .olderOff { background-image:url(‘../common/fotos/arrow_right_off.gif’); color:#C03;
}

And the HTML is just a div near the end of the page called ‘gallerypages’:

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd“>
<html xmlns=”http://www.w3.org/1999/xhtml” dir=”ltr” lang=”en-US”>
<head profile=”http://gmpg.org/xfn/11“>
<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″ />
<title>Lupa Digital | Photography: Collections Gallery</title>
<meta name=”keywords” content=”Lupa Digital Photography Site”/>
<meta name=”description” content=”Lupa Digital Photography”/>
<script src=”../js/example1.js” type=”text/javascript”></script>
<link rel=”stylesheet” href=”../CSS/example1.css” type=”text/css” media=”screen” />
</head>
<body>

<div>

<div id=”content2″>

<div class=”main2″>
<script type=”text/javascript”>
<!–
//globals
var feature = “feature”;
var page = 1;
var featureMatches = 1;
// –>

</script>
<script type=”text/javascript”>
var tabs = new Array(
‘feature’);
var tabCounts = new Array(
’10’);
var gallery_relativityolder = ‘Older Posts’;
var gallery_relativitynewer = ‘Newer Posts’;
</script>
<div class=”maininfo”>
<div class=”outer_gallery”>

<div id=”bcframegaly”>
<div id=”bgbcframegaly”>
<div id=”topbcframegaly”>
<ul>
<li class=”tltbcframegaly”></li>
<li class=”trtbcframegaly”> </li>
</ul>
</div>
<div class=”topbcframetopmargaly”></div>

<div class=”gallists”>
<div class=”ribbon”><p class=”ribbon”></p></div>
<div id=”gallery_relativity”>
<div class=”gallery_relativityitem” id=”featureFilter”></div>
</div>
<div class=”gallery_listing”>
<div id=”features_featureThingDiv” class=”gallery_catagories”>
<div class=”gallery_focus”> <img src=”BLA BLA BLA” alt=”BLA BLA BLA” />
<p class=”gallery_feat”>BLA BLA BLA&nbsp;<sup>BLA</sup></p>
<p class=”gallery_desc”> <b>BLA BLA BLA</b>BLA BLA BLA<br />
<span class=”categoryLink”><a href=”BLA BLA BLA” onclick=”return showGallery(true,this.href);”>BLA BLA BLA</a><span class=”gallery_desc”> / </span></span><span class=”categoryLink”><a href=”BLA BLA BLA”>BLA BLA BLA</a></span></p>
</div>
<div class=”gallery_focus”> <img src=”BLA BLA BLA” alt=”BLA BLA BLA” />
<p class=”gallery_feat”>BLA BLA BLA&nbsp;<sup>BLA</sup></p>
<p class=”gallery_desc”> <b>BLA BLA BLA</b>BLA BLA BLA<br />
<span class=”categoryLink”><a href=”BLA BLA BLA” onclick=”return showGallery(true,this.href);”>BLA BLA BLA</a><span class=”gallery_desc”> / </span></span><span class=”categoryLink”><a href=”BLA BLA BLA”>BLA BLA BLA</a></span></p>
</div>
<div class=”gallery_focus”> <img src=”BLA BLA BLA” alt=”BLA BLA BLA” />
<p class=”gallery_feat”>BLA BLA BLA&nbsp;<sup>BLA</sup></p>
<p class=”gallery_desc”> <b>BLA BLA BLA</b>BLA BLA BLA<br />
<span class=”categoryLink”><a href=”BLA BLA BLA” onclick=”return showGallery(true,this.href);”>BLA BLA BLA</a><span class=”gallery_desc”> / </span></span><span class=”categoryLink”><a href=”BLA BLA BLA”>BLA BLA BLA</a></span></p>
</div>
<div class=”gallery_focus”> <img src=”BLA BLA BLA” alt=”BLA BLA BLA” />
<p class=”gallery_feat”>BLA BLA BLA&nbsp;<sup>BLA</sup></p>
<p class=”gallery_desc”> <b>BLA BLA BLA</b>BLA BLA BLA<br />
<span class=”categoryLink”><a href=”BLA BLA BLA” onclick=”return showGallery(true,this.href);”>BLA BLA BLA</a><span class=”gallery_desc”> / </span></span><span class=”categoryLink”><a href=”BLA BLA BLA”>BLA BLA BLA</a></span></p>
</div>

</div>

</div>
<div id=”gallerypages”></div>
</div>

</div>

</div>

</div>
<!– end outer_gallery –>

</div>
<!– end maininfo div –>
<!– end maincol –>
</div><!– end main2 –>

<!–<div class=”column2″>
<div class=”topbanner”> </div>

</div>–>
<!– end column2 –>
</div>

</div>

<script type=”text/javascript”>
<!–

function callNewTrackEvent(filter){

}
//delete shadow img
var imgs = document.body.getElementsByTagName(“img”);
for (var i = 0; i < imgs.length; i++) {
if (imgs[i].src == “../common/fotos/searchbar_dropshadow.gif”) imgs[i].style.display = “none”;
}
//init features
initFilter();

//var pageSize = this.getPageSize();
//var objOverlay = this.doc.getElementById(‘lbOverlay’);
//var objBody = this.doc.getElementsByTagName(“body”).item(0);
//objOverlay.style.height = pageSize[1] + “px”;
//objOverlay.style.display = ”;

function showGallery( show, src ){

var blanket = document.getElementById(“blanket”);
var gallery = document.getElementById(“gallery”);
var galleryframe = document.getElementById(“galleryframe”);
if( show ){
galleryframe.src = src;
gallery.style.top = document.documentElement.scrollTop + 80 + ‘px’;
blanket.style.visibility = ‘visible’;
gallery.style.visibility = ‘visible’;
}
else{
gallery.style.visibility = ‘hidden’;
galleryframe.src = ‘about:blank’;
blanket.style.visibility = ‘hidden’;
}
return false;
}
// –>

</script>

<!– end main –><div id=”blanket”></div>
<div id=”gallery”>
<a href=”#close” onclick=”return showGallery(false);”>
[ CLOSE ] </a>
<iframe id=”galleryframe” frameborder=”0″ scrolling=”no”> </iframe>
</div>
</body>
</html>

I can post the javascript if needed, I’m just not all that sure anyone wants to have all of it to stare at, but if you are interested in seeing it included here I will gladly paste it.

Thanks for having a look!

to post a comment
JavaScript

10 Comments(s)

Copy linkTweet thisAlerts:
@FangDec 16.2009 — Safari throws an error in example1.js line 364
TypeError: Result of expression 'this.div.document' [undefined] is not an object.[/QUOTE]
Copy linkTweet thisAlerts:
@nitsua327authorDec 16.2009 — Ah...something to investigate. I will check this out and post if I am able to fix or not. Thanks.
Copy linkTweet thisAlerts:
@nitsua327authorDec 16.2009 — Safari throws an error in example1.js line 364[/QUOTE]


OK, I altered this code:
if( is.ns4 )

Thing.prototype.getPosition = function(){

this.position = new Point(

parseInt(this.style.left),

parseInt(this.style.top)

);

return this.position;

}

else

Thing.prototype.getPosition = function(){

this.position = new Point(

parseInt(this.div.offsetLeft),

parseInt(this.div.offsetTop)

);

return this.position;

}

if( is.ns4 )

Thing.prototype.getSize = function(){

this.size = new Point(

[COLOR="Magenta"]this.div.document.width,

this.div.document.height [/COLOR]


);

return this.size;

}

else if( is.ie4 )

Thing.prototype.getSize = function(){

this.size = new Point(

parseInt( this.div.scrollWidth ),

parseInt( this.div.scrollHeight )

);

return this.size;

}

else

Thing.prototype.getSize = function(){

this.size = new Point(

parseInt(this.div.offsetWidth),

parseInt(this.div.offsetHeight)

);

this.style.offsetWidth = this.size.x;

this.style.offsetHeight = this.size.y;

return this.size;

}
[/QUOTE]


to this:


if( is.ns4 )

Thing.prototype.getPosition = function(){

this.position = new Point(

parseInt(this.style.left),

parseInt(this.style.top)

)

return this.position;

}

else

Thing.prototype.getPosition = function(){

this.position = new Point(

parseInt(this.div.offsetLeft),

parseInt(this.div.offsetTop)

)

return this.position;

}

if( is.ns4 )

Thing.prototype.getSize = function(){

this.size = new Point(

[COLOR="Magenta"]parseInt(this.div.width),

parseInt(this.div.height) [/COLOR]


)

return this.size;

}

else if( is.ie4 )

Thing.prototype.getSize = function(){

this.size = new Point(

parseInt( this.div.scrollWidth ),

parseInt( this.div.scrollHeight )

)

return this.size;

}

else

Thing.prototype.getSize = function(){

this.size = new Point(

parseInt(this.div.offsetWidth),

parseInt(this.div.offsetHeight)

)

this.style.offsetWidth = this.size.x;

this.style.offsetHeight = this.size.y;

return this.size;

}
[/QUOTE]


Which now allows 'NEWER POSTS' and 'OLDER POSTS' to be viewable in Safari but the scroll function which slides this section up and down is not working in Safari but it seems to work as expected in IE and FF. I could use some more help here in fixing this. Thanks.
Copy linkTweet thisAlerts:
@nitsua327authorDec 16.2009 — I posted this in the CSS section but it seems that this is more a javascript issue, so sorry for the double post. My original problem was:

I'm having problems with a scroll element when using Safari (on Mac and PC). FF and IE show the following page correctly:

http://www.lupadigitalpanama.com/print/example1.html

At the bottom of the page a 'NEWER POSTS' and 'OLD POSTS' should be viewable but they don't show up using Safari (I am using version 4.0.3 on a PC for testing but its not working on Macs either). I've been at this for about half a day and have had no luck so I'm not sure if its a javascript issue or a CSS issue, but I welcome any bit of advice. IN any event if the 'NEWER POSTS' and 'OLD POSTS' are viewable they are suppose to slide the center page elements up or down. I think the slide part is working but if I was only able to figure out how they could be viewable with Safari I think I will have it working 100%. Your help is appreciated.[/QUOTE]



FANG helped me out:

Safari throws an error in example1.js line 364


TypeError: Result of expression 'this.div.document' [undefined] is not an object. [/QUOTE]


So I looked at the javascript and this is where I am now:

OK, I altered this code:
if( is.ns4 )

Thing.prototype.getPosition = function(){

this.position = new Point(

parseInt(this.style.left),

parseInt(this.style.top)

);

return this.position;

}

else

Thing.prototype.getPosition = function(){

this.position = new Point(

parseInt(this.div.offsetLeft),

parseInt(this.div.offsetTop)

);

return this.position;

}

if( is.ns4 )

Thing.prototype.getSize = function(){

this.size = new Point(

[COLOR="Magenta"]this.div.document.width,

this.div.document.height [/COLOR]


);

return this.size;

}

else if( is.ie4 )

Thing.prototype.getSize = function(){

this.size = new Point(

parseInt( this.div.scrollWidth ),

parseInt( this.div.scrollHeight )

);

return this.size;

}

else

Thing.prototype.getSize = function(){

this.size = new Point(

parseInt(this.div.offsetWidth),

parseInt(this.div.offsetHeight)

);

this.style.offsetWidth = this.size.x;

this.style.offsetHeight = this.size.y;

return this.size;

} [/QUOTE]


to this:


if( is.ns4 )

Thing.prototype.getPosition = function(){

this.position = new Point(

parseInt(this.style.left),

parseInt(this.style.top)

)

return this.position;

}

else

Thing.prototype.getPosition = function(){

this.position = new Point(

parseInt(this.div.offsetLeft),

parseInt(this.div.offsetTop)

)

return this.position;

}

if( is.ns4 )

Thing.prototype.getSize = function(){

this.size = new Point(

[COLOR="Magenta"]parseInt(this.div.width),

parseInt(this.div.height) [/COLOR]


)

return this.size;

}

else if( is.ie4 )

Thing.prototype.getSize = function(){

this.size = new Point(

parseInt( this.div.scrollWidth ),

parseInt( this.div.scrollHeight )

)

return this.size;

}

else

Thing.prototype.getSize = function(){

this.size = new Point(

parseInt(this.div.offsetWidth),

parseInt(this.div.offsetHeight)

)

this.style.offsetWidth = this.size.x;

this.style.offsetHeight = this.size.y;

return this.size;

} [/QUOTE]


Which now allows 'NEWER POSTS' and 'OLDER POSTS' to be viewable in Safari but the scroll function which slides this section up and down is not working in Safari but it seems to work as expected in IE and FF. I could use some more help here in fixing this. Thanks. [/QUOTE]


Hope someone can take a look for me. Much appreciated.
Copy linkTweet thisAlerts:
@FangDec 16.2009 — Update the code online.
Copy linkTweet thisAlerts:
@nitsua327authorDec 16.2009 — Update the code online.[/QUOTE]

....

done :eek:

...Take a look now
Copy linkTweet thisAlerts:
@nitsua327authorDec 17.2009 — this part of the script for the slide may be where Safari is having trouble:

var SLIDE_DEFAULT_DT = 17;

var SLIDE_DEFAULT_CURVE = 0;

var SLIDE_DEFAULT_SPEED = 10;

Thing.prototype.slideTo = function( x, y, speed1, speed2, speed3, dt, curve ){

if( x === null || y === null ) return;

this.pEnd = new Point( x,y );
this.dt = (dt) ? dt : SLIDE_DEFAULT_DT;
this.curve = (curve) ? curve : SLIDE_DEFAULT_CURVE;

var direction = this.pEnd.sub(this.position);
this.totDist = direction.size();

this.speed1 = ( speed1 !== null ) ? speed1 : SLIDE_DEFAULT_SPEED;

if( speed2 !== null ){
if( speed3 !== null ){
//gave all three
this.speed2 = speed2;
this.speed3 = speed3;
}
else{
//gave 1 & 2
this.speed3 = speed2;
this.speed2 = (this.speed1 + this.speed3)/2;
}
}
else{
// gave only 1
if( this.speed1 === 0 ){
this.moveTo( pEnd );
this.onSlideEnd();
}
else{
this.speed3 = this.speed2 = this.speed1;
}
}
this.slideStep();

};

Thing.prototype.slideBy = function( dx, dy, speed1, speed2, speed3, dt, curve ){

this.slideTo( this.position.x + dx, this.position.y + dy, speed1, speed2, speed3, dt, curve );

};

Thing.prototype.slideStep = function(){

var direction = this.pEnd.sub(this.position);
var dist = direction.size();
direction = direction.mult( 1/dist );

// figure out speed
var progress = 2 * ( this.totDist - dist ) / this.totDist;
var perp = direction.perp();

if( progress < 1 ){
var speed = this.speed1 * (1 - progress) + this.speed2 * (progress);
perp = perp.mult( (progress) * this.curve );
}
else if( progress < 2 ){
progress = progress - 1;
var speed = this.speed2 * (1 - progress) + this.speed3 * (progress);
perp = perp.mult( (1 - progress) * this.curve );
}
if( progress > 2 || speed >= dist || dist < 3 ){
this.moveTo( this.pEnd );
return this.onSlideEnd();
}
direction = direction.mult( speed );
this.moveBy( direction.add(perp) );

this.slideTimeout = setTimeout( "Thing.feature." + this.name + ".slideStep()", this.dt );

};

Thing.prototype.killSlide = function( finish ){

clearTimeout( this.slideTimeout );

if( finish ) this.moveTo( this.pEnd );

};

// overwrite me

Thing.prototype.onSlideEnd = function(){};


Still works with FF and IE but not Safari.
Copy linkTweet thisAlerts:
@FangDec 17.2009 — A few changes, although they don't help with safari

Bracket error:#content2 .main2 .maininfo .outer_gallery .gallists{
margin:0px;
color:#ccc;
padding:0px;
overflow:hidden;
overflow-y:hidden;[COLOR="Red"]}[/COLOR]
}

Don't use [I]eval[/I]function initFilter(){

<i> </i>init(); //thing
<i> </i>if( document.cookie.indexOf("leftcolumn15half_currFilter")!=-1 ){
<i> </i> feature = getCookie("leftcolumn15half_currFilter");
<i> </i>}
<i> </i>if( document.cookie.indexOf("leftcolumn15half_currPage")!=-1 ){
<i> </i> page = getCookie("leftcolumn15half_currPage");
<i> </i>}
<i> </i>//remember prior position if cookie is set
<i> </i>if( page!=1 ) window["features_"+feature].moveTo(0,(((page-1)*663)*-1));

<i> </i>setFilter( feature, page, false );
}

function setFilter( feature, page, resetAll ){
//set feature cookie, reset page cookie
document.cookie = 'leftcolumn15half_currFilter='+"feature";
document.cookie = 'leftcolumn15half_currPage='+page;
//set tabs
clearFilterTabs();
tab = document.getElementById("feature"+"Filter");
tab.className = "gallery_relativityitemon";
if( resetAll ){
for( var i=0; i&lt;tabs.length; i++ ){ //reset all features_ divs
window["features_" +tabs[i]].moveTo(0,0);

<i> </i> }
<i> </i>}
<i> </i>//show features
<i> </i>callNewTrackEvent(feature);
<i> </i>showFeatures( feature, page );



<i> </i>return false;
}


function showFeatures( feature, page ){
var gallery_focusDiv = document.getElementById("features_"+"feature"+"ThingDiv");
for( var i=0; i&lt;tabs.length; i++ ){ //hide all features_ divs
window["features_" +tabs[i]].hide();
}
window["features_" + feature].show();

<i> </i>writePagination( feature, page );

<i> </i>return false;
}

function writePagination( feature, page ){

<i> </i>var numMatches = parseInt(tabCounts[getTabPos(feature)],10);
<i> </i>page = parseInt(page,10);
<i> </i>var olderOn = '&lt;a href="#older" class="older" onclick="return paginate('' + 'feature' + '','' + (page+1) + '')"&gt;' + gallery_relativityolder + '&lt;/a&gt;';
<i> </i>var newerOn = '&lt;a href="#newer" class="newer" onclick="return paginate('' + 'feature' + '','' + (page-1) + '')"&gt;' + gallery_relativitynewer + '&lt;/a&gt;';
<i> </i>var older = ( page &gt;= numMatches/4 ) ? '&lt;a class="older olderOff"&gt;' + gallery_relativityolder + '&lt;/a&gt;' : olderOn;
<i> </i>var newer = ( page == 1 ) ? '&lt;a class="newer newerOff"&gt;' + gallery_relativitynewer + '&lt;/a&gt;' : newerOn;
<i> </i>document.getElementById("gallerypages").innerHTML = '' + older + newer;
}

function getTabPos( feature ){
var pos = null;
for( var i=0; i&lt;tabs.length; i++ ) if( tabs[i] == feature ) pos = i;
return pos;
}

function paginate( feature, page ){
page = parseInt(page,10);
if( page == 0 ) page = 1;
document.cookie = 'leftcolumn15half_currPage=' + page;
writePagination( feature, page );
window["features_" + feature].slideTo( 0,(663*(page-1))*-1, 10, 80, 10 );
return false;
}
Copy linkTweet thisAlerts:
@nitsua327authorDec 17.2009 — Thanks. I saw a "eval is evil" when validating on jslint but was ignorant on what to use as an alternative. I'm going to apply this and then post back. Your help is really appreciated.
Copy linkTweet thisAlerts:
@nitsua327authorDec 17.2009 — Alright, I placed your code (to eliminate eval) and updated the page online and it is working in the same manner as before - so as you stated: this didn't solve the safari issue but the script is more efficient and I like that. (and JSLint throws less errors)

Also thanks for finding that bracket error in my css, this is also updated online.

Which leaves me having the original issue of Safari being fussy about something. Any ideas? Fixes?

Much appreciated.

I'm also wondering now why in FF the slide goes much faster than in IE. This is of course secondary to it not working at all in Safari but Fang has inspired me to have this run with as little errors as possible and with everyhting accounted for and slide speed seems to not be used based on this JSLint message:

515-542 "slideStep"()

Unused speed

Variable direction, dist, perp, progress
[/QUOTE]


It would be great if this and the Safari issue were one in the same but it probably isn't.

Thanks. Any additional help would be most welcome.
×

Success!

Help @nitsua327 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...