473,796 Members | 2,376 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ff event problem

hi all, this code is for a picture viewer. yes, this is my first code
and my first piece of programming so i maybe simply be missing some key
notions here. the problem is: the nav onclick event buttons to flip
through the pics only work in IE and not in FF, i havnt tested anywhere
else. I have tried lots of thing such as including the code directly
after the event or in the headleft and headright functions, replacing
the event function by a simple alert(); **onclick = function () {
alert('there'); }**, or assigning the events after their elements have
been inserted into DOM,...the bastard simply doesnt recognise the
event although i assign the top nav bar events the same way. The page
can be found at http://max.nugraphic.com/ajax/aixaqua/ o know it still
looks ugly especially in IE but I havnt gotten to the design yet.

thank you so much, im losing patience

photo.js:
function createphotobox( ) {
var contentdiv = document.getEle mentById('conte nt');
var photobox = document.create Element('div'); //pic-img tag
container
photobox.id = "photobox";
contentdiv.appe ndChild(photobo x);
addphoto(photob ox); //pic-img tag into designated container
addnav(contentd iv); //nav underneath pic conatiner above
}

function addphoto(el) { // lay pic
var pic = document.create Element('img');
pic.src = phppaths[0]; //fine array imported from php
pic.num = 0; //temporary pic index system..
pic.id = "pic";
pic.width = "480";
el.appendChild( pic);
}

function addnav(el) { //Add 2 nav items under
pic
var nav = document.create Element('div');
nav.id = "photonav";
var navleft = document.create Element('img');
var navright = document.create Element('img');
navleft.src = "images/photonav_left.g if";
navright.src = "images/photonav_right. gif";
navleft.onclick = headleft; //<<<problemati c
events
navright.onclic k = headright;
el.appendChild( nav);
nav.appendChild (navleft);
nav.appendChild (navright);
}

function headleft(event) {
currentpic('lef t');
return false;
}

function headright(event ) {
currentpic('rig ht');
return false;
}

function currentpic(dire ction) {
var dir = direction;
var pic = document.getEle mentById('pic') ;
var a = pic.num;
switch(dir) {
case 'right':
pic.src = phppaths[a+1];
pic.num++;
break;
case 'left':
pic.src = phppaths[a-1];
pic.num--;
break;
default:
break;
}
}

Feb 27 '06 #1
1 1537
mx*****@yahoo.c a wrote :
hi all, this code is for a picture viewer. yes, this is my first code
and my first piece of programming so i maybe simply be missing some key
notions here. the problem is: the nav onclick event buttons to flip
through the pics only work in IE and not in FF, i havnt tested anywhere
else. I have tried lots of thing such as including the code directly
after the event or in the headleft and headright functions, replacing
the event function by a simple alert(); **onclick = function () {
alert('there'); }**, or assigning the events after their elements have
been inserted into DOM,...the bastard simply doesnt recognise the
event although i assign the top nav bar events the same way. The page
can be found at http://max.nugraphic.com/ajax/aixaqua/
I checked your page and I would be extremely surprised if you really
need to dynamically create image, dynamically create holding box,
etc,,.. just to switch images, just to replace images. I'm sure your
webpage does not need to dynamically create new image objects but to
just replace current ones.

Your page has other problems:
http://validator.w3.org/check?uri=ht...line&verbose=1

You may want to use HTML Tidy to fix the others:

http://users.skynet.be/mgueury/mozilla/

Your page also uses fixed font size.

"Do not specify the font-size in pt, or other absolute length units.
They render inconsistently across platforms and can't be resized by the
User Agent (e.g browser). Use relative length units such as percent or
(better) em"
http://www.w3.org/QA/Tips/font-size
o know it still looks ugly especially in IE but I havnt gotten to the design yet.
I recommend to not break an image into several ones (headerDivOne,
headerDivTwo, etc.): you increase the number of http connections to the
server by doing that and you make the download (and page parsing, page
rendering) longer, not shorter.

thank you so much, im losing patience

photo.js:
function createphotobox( ) {
var contentdiv = document.getEle mentById('conte nt');
var photobox = document.create Element('div'); //pic-img tag
container
photobox.id = "photobox";
Do you *absolutely* need to give an id to that object? I'm just wondering.
contentdiv.appe ndChild(photobo x);
addphoto(photob ox); //pic-img tag into designated container
addnav(contentd iv); //nav underneath pic conatiner above
}

function addphoto(el) { // lay pic
var pic = document.create Element('img');
pic.src = phppaths[0]; //fine array imported from php
pic.num = 0; //temporary pic index system..
That "num" looks like wrong code to me. You can't just declare an
attribute like that an expect everything to behave just like you wish.
Why not just use a global variable ... if this num storing a number is
really the only way to do your slideshow application...
pic.id = "pic";
pic.width = "480";
el.appendChild( pic);
}

function addnav(el) { //Add 2 nav items under
pic
var nav = document.create Element('div');
nav.id = "photonav";
var navleft = document.create Element('img');
var navright = document.create Element('img');
navleft.src = "images/photonav_left.g if";
navright.src = "images/photonav_right. gif";
navleft.onclick = headleft; //<<<problemati c
events
navleft.onclick = new Function("[parameters]", "[function body]");

navright.onclic k = headright;
el.appendChild( nav);
nav.appendChild (navleft);
nav.appendChild (navright);
}

function headleft(event) {
currentpic('lef t');
return false;
}
Why an intermediary function? Why not call directly the adequate code
(and only the needed code) to be executed, which would be executed (from
currentpic(dire ction))?
Also, why the return false?

function headright(event ) {
currentpic('rig ht');
return false;
}

function currentpic(dire ction) {
var dir = direction;
var pic = document.getEle mentById('pic') ;
var a = pic.num;
switch(dir) {
case 'right':
pic.src = phppaths[a+1];
pic.num++;
break;
case 'left':
pic.src = phppaths[a-1];
pic.num--;
break;
default:
break;
}


Why use a switch if you have only 2 alternatives? Why not just use an
if..then..else structure? Why use another variable (dir) and not direction?

To me, your webpage only needs to implement a slideshow. You do not need
to *create dynamically* images, to *create dynamically* photobox and nav
images, etc..

I understand you're developing the page. I see many positive aspects to
your webpage code: e.g. you use good meaningful, self-explanatory
identifiers to your variables. That helps reviewing code, code
maintenance, etc.

Some other aspects of your javascript code is debattable. If you use a
parameter in your function, then it is because your function body is
going to make an use out of it; otherwise do not declare one.

E.g.: function selectedmenu(ev ent)
should make use of that event parameter.

Also, best (general recommendation; preferable recommendation) is to
avoid having function calling other functions: doing that avoids
problems and code maintenance (spaghetti coding).

Gérard
--
remove blah to email me
Feb 27 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
7048
by: Andy Read | last post by:
Hello all, I have the requirement to produce source code that produces an object hierarchy. Example: Root | Folder 1
13
7500
by: Manuel Lopez | last post by:
I have a puzzling form timer problem that I didn't experience prior to Access 2003 (though I'm not sure access 2003 is to blame). Here's the situation: a computer has two access 2003 databases on it, a frontend and a backend. Case 1: If vba code on the frontend updates many rows (360,000) on the backend, a form's timer event (from the frontend) will stop firing until the user gives the form focus. (Note that the update itself always...
6
2857
by: Michael Johnson Jr. | last post by:
I am trying to handle a button click event, which updates a web control table with data. The button is dynamically created in the table itself. When I call updateTable() in the Page_Load the new data from the button is not available at this time as to allow the table to properly update. So basically, I need to call UpdateTable() twice, once from page load and once from button. This causes problems with my application, and I was trying...
4
2126
by: The Alchemist | last post by:
I am having a problem with a dynamically-generated Datagrid. It is important to point out that this problem does not exist with a design-time created Datagrid, but only with a dynamically generated Datagrid in a Web Custom Control (WCC) : The datagrid has LinkButton Column which has a select LinkButton for each row. When this button is clicked, the Datagrid raises its 'ItemCommand' event which captures the information for that row and...
9
14461
by: Marcelo Cabrera | last post by:
Hi, I have a user control that in turn creates a bunch of webcontrols dynamically and handles the events these webcontrols raise. It used to work fine on ASP .Net 1.1 but when compiled on 2.0 it does not. The problem is that the webcontrols get created on the OnLoad event of the usercontrol and the event handlers are assigned at the same time. I have to click twice on the controls for the events to be raised, the first time nothing...
9
2472
by: jeff | last post by:
New VB user...developer... Situation...simplified... - I want to wrap a pre and post event around a system generated where the pre-event will always execute before the system event and the post event will always execuate after the system is completed... - I want to wrap this functionality in a framework, so I could possibly have 3 or 4 levels of inherited objects that need to have these pre / post events executed before and after the...
6
3947
by: hemant.singh | last post by:
Hi all, I am trying to get a way by which I'll know exactly when user goes out of my site by clicking on close button in browser, So that w/e user click close button in browser, I can send a signal to server. This seems to be achievable with body unload events, but it is little too much, as even if user navigate within my site, this event will be generated, this can be avoided by handling onclick of each link, so that I'll know exactly...
14
2123
by: Snor | last post by:
I'm attempting to create a lobby & game server for a multiplayer game, and have hit a problem early on with the server design. I am stuck between using a threaded server, and using an event driven server. I've been told time and time again that I should use an event driven server design (that is, use twisted). There is a lot of interaction between the clients and they would often need to write to the same list of values, which of course...
2
1623
by: cty0000 | last post by:
Please anybody help me... I have some serious problem.. I'm doing to keep equpiment list(string).. In my code, there are 3 page which are having 4 equpiment ID (user control.) like this window FORM ==================================================================
3
1825
by: cty0000 | last post by:
Please anybody help me... I have some serious problem.. I'm doing to keep equpiment list(string).. In my code, there are 3 page which are having 4 equpiment ID (user control.) like this window FORM
0
9679
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9527
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10223
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10172
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10003
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7546
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5441
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4115
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.