Set a DIV to be a footer: lowest coordinates in a page

P

pamelafluente

Thank you Benjamin!! You are a star!

Beautiful code.

-Pam

PS
I am studying javascript. I like it, but I am used to tools like
debuggers and intellisense (I work with VS2005/ASP.NET). Is there
something similar for javascript? My greatest problem is to remember
all the objects members names and to type correctly the statements.
Also, the issues about cross compatibility make things more
complicated.

I noticed many people use underscore "_" to start variable names. Is
that a style or some kind of compatibility trick?



Benjamin ha scritto:
function afunc() {
var search = document.body.getElementsByTagName("*");
if (search.length <= 1) {
return;
}
var i = 0;
var bottomPos = 0;
var bottomElem = 0;
var offsetY = 0;
offsetObj;
for (i = 0; i < search.length; i++) {
if (search.id = "myFooter") {
continue;
}
offsetObj = search;
while (offsetObj) {
offsetY += (offsetObj.offsetTop +
offsetObj.offsetHeight);
offsetObj = offsetObj.offsetParent
}
bottomPos = (offsetX > bottomPos) ? offsetX : bottomPos;
}
var myFooter = document.getElementById("myFooter");
myFooter.style.position = "absolute";
var your Padding = 50;
myFooter.style.top = bottomPos + yourPadding + "px";
}
trigger this function like this: <body onload="afunc()">
correct

Benjamin,

I will say in word:


If page contains nothing or only the footer DIV
there is nothing to do. Exit the void function.


define 3 variables. The first variable is for iteration
in the collection of page elements. The second
to store the bottom position. And the third
to store the element which featured such
position.


Iterate on all the elements different fron the footer DIV
to find out which is has lowest position


Once you find it assign the footer position as the position
of the lowest element plus some vertical offset

//

Thanks

-P
 
L

Laurent Bugnion

Hi,

(e-mail address removed) wrote:

PS
I am studying javascript. I like it, but I am used to tools like
debuggers and intellisense (I work with VS2005/ASP.NET). Is there
something similar for javascript? My greatest problem is to remember
all the objects members names and to type correctly the statements.
Also, the issues about cross compatibility make things more
complicated.

There is some JavaScript Intellisense in Visual Studio 2005, but it's
limited. Since JavaScript is a very flexible language, where you can add
properties to an object on runtime, it's difficult to implement
Intellisense for that language.

I still recommend VS2005 for JavaScript development, if only because you
can debug the client and the server in the same application, using the
client-side script debugger and the CLR debugger on the server. It's
really handy to start both sides of an application using F5 and to jump
form one to the other (for example for webservices...)

Cross-compatibility was worse in the past, and is still an issue,
however it's possible to develop JavaScript code which will run on IE
anf Firefox without too much hassle. Testing in Firefox and porting to
IE usually gives better results as FF is stricter.

I noticed many people use underscore "_" to start variable names. Is
that a style or some kind of compatibility trick?

In OOP, some programmers prefix member variables in an object with "_"
or "m_". Similarly, static members are sometimes prefixed with "s_".
Some firms have guidelines regulating the use of such prefixes, as well
as hungarian notation, etc...

For "private" developers, it's a matter of taste, of habit, etc... It
doesn't have a functionality of its own.

HTH,
Laurent
 
R

Richard Cornford

Laurent said:
(e-mail address removed) wrote:
There is some JavaScript Intellisense in Visual Studio 2005, but it's
limited. Since JavaScript is a very flexible language, where you can
add properties to an object on runtime, it's difficult to implement
Intellisense for that language.
<snip>

The ability to add properties to objects at runtime is certainly a
problem for any type of Intelligence. Others include knowing which
objects to report properties for, as without a language defined concept
of what qualifies as a 'class', and with all objects in the langue
being as dynamic as all others, it is difficult for software to see
which structures and objects are implementing the 'class' concept (is a
function that returns a function just a mechanism for doing something
or is it a factory for a class that just happens to use function
objects for its instances?). Another problem is the inconsistencies in
browser DOMs as being told that a document object has a 'styleSheets'
property may tend to promote the writing of code that assumes it does.

Richard.
 
P

pamelafluente

I still recommend VS2005 for JavaScript development, if only because you
can debug the client and the server in the same application, using the
client-side script debugger and the CLR debugger on the server. It's
really handy to start both sides of an application using F5 and to jump
form one to the other (for example for webservices...)

Wait a moment!
I do have VS 2005. Are you saying that I can take a javascript function
or script file (js) and debug / run it with my VS IDE ? How would that
be exactly achieved?

-Pam
 
L

Laurent Bugnion

Hi,

Wait a moment!
I do have VS 2005. Are you saying that I can take a javascript function
or script file (js) and debug / run it with my VS IDE ? How would that
be exactly achieved?

-Pam

First make sure that IE has "script debug" enabled:

Internet Properties / Advanced / Disable script debugging must be UNCHECKED

Then, in VS 2005, place a breakpoint in your JavaScript code and press F5.

Alternatively, you can start IE, then choose the menu Debug / Attach to
process. Choose the instance of IE which you want to run the script in,
then click on "Select". Then load the page in the IE, and you can debug
the script.

HTH,
Laurent
 
P

pamelafluente

Infact it was disabled.

THANK YOU Laurent!!!

This piece of information is INVALUABLE to me. I was struggling with
javascript and most of my common errors are due to incorrect typing,
casing. But working within Visual Studio that checks for me and also
shows the variable contents while running, has some intellisense, is
just what I needed. It also check for a lot of other things and helps
getting better organized.

It's all another world :)

Thanks again this really helps a lot.

-Pam

Laurent Bugnion ha scritto:
 
L

Laurent Bugnion

Hi,

Infact it was disabled.

THANK YOU Laurent!!!

This piece of information is INVALUABLE to me. I was struggling with
javascript and most of my common errors are due to incorrect typing,
casing. But working within Visual Studio that checks for me and also
shows the variable contents while running, has some intellisense, is
just what I needed. It also check for a lot of other things and helps
getting better organized.

It's all another world :)

Thanks again this really helps a lot.

-Pam

Happy to help. Note that if Firefox or other Mozilla based browsers are
also in your target list, you want to download Venkman, which is the
JavaScript debugger for this family of browsers.

HTH,
Laurent
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,772
Messages
2,569,589
Members
45,100
Latest member
MelodeeFaj
Top