Email conversation
From | Ayodele Smith - Jackson |
To | Me |
Subject | Determining page/scrollable height of a php dynamically created page |
Date | 12 October 2006 23:40 |
Greetings, I've looked through your other emails, and I didn't offhand see
anything that fit my problem exactly, I did try a couple things and didn't
get the results I wanted. Perhaps you can help me clarify.
To explain, I have a website the uses a series of php functions to put
itself together, so that when we want to modify, headers and footers and the
sidebar we only have to modify one document. So most of the internal pages
look something like this
<?php whole_top($bg); ?>
<div id="contentlayer">
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td align="left">
BLAH BLAH BLAH
</td>
</tr>
</table>
</div>
<?php content($bg); ?>
<?php whole_bottom($bg); ?>
There is some php before that to determine $bg but my problem is that the
content varies in length on each page. On one page I have it bringing in
dynamic content from a text file using another function. Now to go more into
depth, our website uses transparency. We have the topper and sides and then
in a table we have 2 div tags, one div tag is the contentlayer above set to
z-index: 3 and the second is the content($bg) inside that function it
displays a div with a transparent background set to z-index: 0 with absolute
positioning called fadehunt and fadefita Now in Firefox I am able to do
var contentheight = document.getElementById('contentlayer').clientHeight;
var contentwidth = document.getElementById('contentlayer').clientWidth;
document.getElementById('fadehunt').style.height = contentheight - 20;
document.getElementById('fadehunt').style.width = contentwidth;
I do this at the bottom of the page after the <?php content($bg); ?>
But I cannot get the proper width and height values in Internet Explorer
I've tried
document.getElementById('contentlayer').innerHTML;
document.getElementById('contentlayer').offsetParent;
document.getElementById('contentlayer').offsetLeft;
document.all['contentlayer'].offsetHeight;
window.pageXOffset;
document.body.scrollLeft;
document.documentElement.scrollLeft;
window.offsetLeft;
document.body.offsetLeft;
document.documentElement.offsetLeft;
I tried using your link location script findPosition( oLink ) to find the
position inside of the javascript;
Most of these either come up as 0 or undefined, perhaps I am using them
wrong, I am calling all of these after the contentlayer has been filled.
maybe you can help.
Ayo
From | Me |
To | Ayodele Smith - Jackson |
Subject | Re: Determining page/scrollable height of a php dynamically created page |
Date | 13 October 2006 11:18 |
Ayo,
> in Firefox I am able to do
> [snip]
> But I cannot get the proper width and height values in Internet Explorer
What does Opera do? Does it work there? Any messages in the error console?
In any case, I _think_ the problem relates to IE not drawing the page until
layout is complete. You are running your script too early. Wait for onload
to fire before trying to take measurements.
Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
From | Ayodele Smith - Jackson |
To | Me |
Subject | Re: Dynamically resizing iframe or shopping card and getting Error: uncaught exception: Permission denied to get property |
Date | 9 November 2006 09:24 |
I am a contract web designer and though I have tried and tried i cannot get
a piece of javascript to execute properly.
Let me explain. I have a page with some content on the top and bottom and in
the middle inside of a table I have an iframe which points to a shopping
cart which is in the same domain just in a different directory
"/catalog/index.php"
On the parent page I have a function
function shea_height(height) {
if (document.getElementById('myframe'))
document.getElementById('myframe').height = height + 10;
if (document.frames){
var know = document.frames("myframe").document.body.scrollHeight;
document.getElementById('myframe').height = know;
}
}
and at the bottom of the child/internal pages/internal iframes is
var contentheight;
if (document.getElementById('content').clientHeight){
contentheight = document.getElementById('content').clientHeight;
window.parent.shea_height(contentheight);
}
I do not have problems with the first page /catalog/index.php in any
browser, since the javascript doesn't run until the bottom of the page it
reads correctly as I have read in your previous emails etc.
But when I click on another page inside the iframe I get Error: uncaught
exception: Permission denied to get property Window.shea_height
the other pages are located again on the same server they are
"/catalog/login.php"
"/catalog/product_reviews_info.php"
etc etc
Why am i getting that exception?
Am I only allowed to call that function once?
Do I need to reload the entire page and iframe?
or once the page is loaded am I not allowed to call that parent function
Thanks for the help ahead of time,
Ayo
From | Me |
To | Ayodele Smith - Jackson |
Subject | Re: Dynamically resizing iframe or shopping card and getting Error: uncaught exception: Permission denied to get property |
Date | 13 November 2006 09:10 |
Ayo,
> I have an iframe which points to a shopping cart which is in the same
> domain just in a different directory "/catalog/index.php"
Are you _sure_ it is on the same domain? Remember that browsers treat
different port numbers as different domains. They also treat http and https
as different domains.
> Why am i getting that exception?
If it is not the problem I mentioned above, then I am afraid I do not know
offhand. I would need to see an example of it myself in order to debug.
> Am I only allowed to call that function once?
I do not see any reason why a browser would enforce that restriction.
> Do I need to reload the entire page and iframe?
no.
From | Ayodele Smith - Jackson |
To | Me |
Subject | Re: Dynamically resizing iframe or shopping card and getting Error: uncaught exception: Permission denied to get property |
Date | 14 November 2006 00:35 |
Hello again,
I wrote you about the permission denied to get property, I can show you a
sample, if you have time at http://www.example.com/test.html
Thank you,
Ayodele
From | Me |
To | Ayodele Smith - Jackson |
Subject | Re: Dynamically resizing iframe or shopping card and getting Error: uncaught exception: Permission denied to get property |
Date | 14 November 2006 08:48 |
Ayodele,
> I wrote you about the permission denied to get property, I can show you
> a sample, if you have time at http://www.example.com/test.html
Your site starts off as this:
http://www.example.com/...
You then load the first page in the iframe like this:
src="catalog/login.php"
Meaning that it is taken as relative the the current domain, so it is:
http://www.example.com/catalog/login.php
This part works fine.
Then every link points to this:
http://example.com/...
JavaScript considers those to be different domains, which is why you get the
security exception.
There is no real need for you to use absolute links, but if you really feel
you must, then you should use the same domain as you started with.
As a side point, you currently serve your site using two separate domains.
You might as well use only one, and use the 'Location:' HTTP header to
redirect them if they use the other one.
Tarquin
From | Ayodele Smith - Jackson |
To | Me |
Subject | thank you |
Date | 14 November 2006 23:37 |
thank you very very much!
I thought my code was wrong or something but that resizing iframe works beautifully now.
Is there anything I can do to compensate you for the time and energy you spent helping me?
Ayo