PDA

View Full Version : Javascript programmer needed - Cash offered!


Beaker
11-08-2004, 11:44
Hi

I need a freelance javascript programmer to do some minor remedial work on my website template.

At present, the template can be seen here (http://www.askweddings.co.uk).

Now if you are viewing this page in Microsoft Internet Explorer, then the menu displays correctly (i.e. if you hover over Directory, you see all the options, with the first one lining up over the Directory image).

However, as discovered from other people posting on the General Discussion forum, when the page is displayed in Firefox or Netscape browsers, the menu options appear to be offset by about 200 pixels across and 1-2px down.

I need someone to write me some javascript to compensate for this if possible. A small fee will be offered to the person who posts a working solution. Feel free to 'View Source' for the existing javascript.

Thanks in advance for any postings :thumbs:

Beaker
11-08-2004, 18:58
No-one interested :( ?

HaloMan
11-08-2004, 20:53
Okay, I've got this working. Considering I don't know much javascript, it's a small miracle.

From:

for (i=1; i < 7; i++) {
//aDivID=aDivs[i].id;
//document.getElementById("option"+i).style.left = parseInt(document.getElementById("option"+i).style.left) + xd + "px";
document.getElementById("option"+i).style.left = (getRealPos(document.images["askweddingslogo"],"Left") + xd) + "px";
//alert(document.getElementById("option"+i).style.left)
//document.getElementById(aDivID).style.top = parseInt(document.getElementById(aDivID).style.top) + yd + "px";
//if (aDivs[i].id == "imcmain" || aDivs[i].id == "info0") {
// document.getElementById(aDivID).style.visibility = "visible";
//**
//alert(i+":"+document.getElementById("option"+i).style.left);
**
**


To:

for (i=1; i < 7; i++) {
//aDivID=aDivs[i].id;
//document.getElementById("option"+i).style.left = parseInt(document.getElementById("option"+i).style.left) + xd + "px";
if (what == "moz") {
document.getElementById("option"+i).style.left = (getRealPos(document.images["askweddingslogo"],"Left") - 15) + "px";
document.getElementById("option"+i).style.top = "82px";
**
else {
document.getElementById("option"+i).style.left = (getRealPos(document.images["askweddingslogo"],"Left") + xd) + "px";
**;
//alert(document.getElementById("option"+i).style.left)
//document.getElementById(aDivID).style.top = parseInt(document.getElementById(aDivID).style.top) + yd + "px";
//if (aDivs[i].id == "imcmain" || aDivs[i].id == "info0") {
// document.getElementById(aDivID).style.visibility = "visible";
//**
//alert(i+":"+document.getElementById("option"+i).style.left);
**
**


AHA, sorted it. It now works 100% fine. Hope you don't mind giving that small fee you promised, as I am a poor student :)

Beaker
11-08-2004, 22:50
HaloMan, you're a star - works fine in Firefox / Moz now :thumbs:

But it's out on Netscape now by a few pixels :( , but a lot better than before.

I'm assuming I need to add another 'if (what == "moz")' routine, but what is it for netscape? moz=mozilla, but does netscape=netscape, or is it just "net"?

P.S. Drop me an email to webmaster@askweddings.co.uk, and I'll sort the cash out.

Cheers

HaloMan
12-08-2004, 00:00
Heya,

What version of Netscape are you referring too and I'll have a bash at it? The reason it's "Moz" is because it's set to that earlier in the routine as it has a way of checking which platform it's using based on it's Javascript implementation. Netscape 4 is set to "NS4".

MrBoombastic
12-08-2004, 08:10
If you already intend to, my apologies, but make sure you make provision for people with javascript not enabled in their browser. :)

HaloMan
12-08-2004, 20:21
Right, you can get it to work in Opera 100% too. This requires some extra lines of code. I'm not sure about Netscape 7.

Change:

if (document.layers) {
// alert ("Running Netscape 4");
layerRef="document.layers";
styleSwitch="";
visibleVar="show";
screenSize = window.innerWidth;
what ="ns4";
** else if(document.all){
// alert ("Running IE");
layerRef="document.all";
styleSwitch=".style";
visibleVar="visible";
screenSize = document.body.clientWidth + 18;
what ="ie";


to


if (document.layers) {
// alert ("Running Netscape 4");
layerRef="document.layers";
styleSwitch="";
visibleVar="show";
screenSize = window.innerWidth;
what ="ns4";

** else if(window.opera) {
// alert ("Running Opera");
layerRef="document.all";
styleSwitch=".style";
visibleVar="visible";
screenSize = document.body.clientWidth + 18;
what ="opr";

** else if(document.all){
// alert ("Running IE");
layerRef="document.all";
styleSwitch=".style";
visibleVar="visible";
screenSize = document.body.clientWidth + 18;
what ="ie";


This will detect if Opera is being run, as otherwise it believes it's IE.

Then change:

if (what == "moz") {
document.getElementById("option"+i).style.left = (getRealPos(document.images["askweddingslogo"],"Left") - 15) + "px";
document.getElementById("option"+i).style.top = "82px";
**
else {
document.getElementById("option"+i).style.left = (getRealPos(document.images["askweddingslogo"],"Left") + xd) + "px";
**;


to:


if (what == "ie") {
document.getElementById("option"+i).style.left = (getRealPos(document.images["askweddingslogo"],"Left") + xd) + "px";
** else {
document.getElementById("option"+i).style.left = (getRealPos(document.images["askweddingslogo"],"Left") - 14) + "px";
document.getElementById("option"+i).style.top = "82px";
**;


Or you can just use the version I uploaded here (http://defaced.co.uk/halo/weddings.htm) with all the changes already made :)

Beaker
15-08-2004, 20:45
Thanks to Haloman for spotting this error and sorting the problem :thumbs: