HighDots Forums  

<a href='#' onClick="fun()"; is not working in IE

Javascript JavaScript language (comp.lang.javascript)


Discuss <a href='#' onClick="fun()"; is not working in IE in the Javascript forum.

Reply
 
Thread Tools Display Modes
  #1  
Old   
prathapavp@gmail.com
 
Posts: n/a

Default <a href='#' onClick="fun()"; is not working in IE - 05-21-2008 , 02:02 AM






hi all,

We r working on ERP sys and am doing crossBrowser
compatibility.
The problem is am not able to load one function by onClicking the
refrence text .

could u please help me out.


The code is looking like this........


name="<a href='#' onClick = 'javascript:editCategoryDimmershow123("+id
+");'>"+category.name;+"</a>"



Reply With Quote
  #2  
Old   
Álvaro G. Vicario
 
Posts: n/a

Default Re: <a href='#' onClick="fun()"; is not working in IE - 05-21-2008 , 02:20 AM






prathapavp (AT) gmail (DOT) com escribió:
Quote:
name="<a href='#' onClick = 'javascript:editCategoryDimmershow123("+id
+");'>"+category.name;+"</a>"
1. Why '#'? Provide a valid alternative URL for the task or just get rid
of the <a> tag.

2. Why 'javascript:'? The onclick attribute expects javascript code, not
an URI.

3. Does it work if you remove the ";" character so you close the <a> tag?



--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--


Reply With Quote
  #3  
Old   
VK
 
Posts: n/a

Default Re: <a href='#' onClick="fun()"; is not working in IE - 05-21-2008 , 02:30 AM



On May 21, 11:02 am, prathap... (AT) gmail (DOT) com wrote:
Quote:
hi all,

We r working on ERP sys and am doing crossBrowser
compatibility.
The problem is am not able to load one function by onClicking the
refrence text .

could u please help me out.

The code is looking like this........

name="<a href='#' onClick = 'javascript:editCategoryDimmershow123("+id
+");'>"+category.name;+"</a>"
Reason:

http://groups.google.com/group/comp....718930ba71d113

Proper way:

var lnk = document.createElement('A');
lnk.appendChild(document.createTextNode(category.n ame));
lnk.href = category.name;
lnk.args = {
'id' : id,
// other params if needed
};
lnk.title = popup.helpPrompt // optional
lnk.onclick = editCategoryDimmershow123;
// ...
yourContainer.appendChild(lnk);

with editCategoryDimmershow123 like

editCategoryDimmershow123(e) {
if ((typeof event == 'object') &&
('returnValue' in event)) {
event.cancelBubble = true;
event.returnValue = false;
}
else {
e.stopPropagation();
e.preventDefault();
}
var id = this.args.id;
// do the rest
}

There are other ways as well but this seems the most flexible in
relevance of the arguments.


Reply With Quote
  #4  
Old   
vp.softverm@gmail.com
 
Posts: n/a

Default Re: <a href='#' onClick="fun()"; is not working in IE - 05-23-2008 , 05:24 AM



On May 21, 12:20 pm, "Álvaro G. Vicario"
<alvaroNOSPAMTHA... (AT) demogracia (DOT) com> wrote:
Quote:
prathap... (AT) gmail (DOT) com escribió:

name="<a href='#' onClick = 'javascript:editCategoryDimmershow123("+id
+");'>"+category.name;+"</a>"

1. Why '#'? Provide a valid alternative URL for the task or just get rid
of the <a> tag.

2. Why 'javascript:'? The onclick attribute expects javascript code, not
an URI.

3. Does it work if you remove the ";" character so you close the <a> tag?

--
--http://alvaro.es- Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web:http://bits.demogracia.com
-- Mi web de humor al baño María:http://www.demogracia.com
--
hi thanks for the reply actually
i tried with href it was not working that's why i changed
it.
javascript: is for we r refering that function from another js file
thats wy


Reply With Quote
  #5  
Old   
Álvaro G. Vicario
 
Posts: n/a

Default Re: <a href='#' onClick="fun()"; is not working in IE - 05-23-2008 , 05:46 AM



vp.softverm (AT) gmail (DOT) com escribió:
Quote:
hi thanks for the reply actually
i tried with href it was not working that's why i changed
it.
javascript: is for we r refering that function from another js file
Where did you read about that? It doesn't trigger any error but it's of
no use. You can write "godsavethequeen:alert('Hello, World!')" and it'll
still work. I suppose JavaScript considers it a label.


--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--


Reply With Quote
  #6  
Old   
vp.softverm@gmail.com
 
Posts: n/a

Default Re: <a href='#' onClick="fun()"; is not working in IE - 05-23-2008 , 05:57 AM



On May 21, 12:30 pm, VK <schools_r... (AT) yahoo (DOT) com> wrote:
Quote:
On May 21, 11:02 am, prathap... (AT) gmail (DOT) com wrote:

hi all,

We r working on ERP sys and am doing crossBrowser
compatibility.
The problem is am not able to load one function by onClicking the
refrence text .

could u please help me out.

The code is looking like this........

name="<a href='#' onClick = 'javascript:editCategoryDimmershow123("+id
+");'>"+category.name;+"</a>"

Reason:

http://groups.google.com/group/comp....718930ba71d113

Proper way:

var lnk = document.createElement('A');
lnk.appendChild(document.createTextNode(category.n ame));
lnk.href = category.name;
lnk.args = {
'id' : id,
// other params if needed};

lnk.title = popup.helpPrompt // optional
lnk.onclick = editCategoryDimmershow123;
// ...
yourContainer.appendChild(lnk);

with editCategoryDimmershow123 like

editCategoryDimmershow123(e) {
if ((typeof event == 'object') &&
('returnValue' in event)) {
event.cancelBubble = true;
event.returnValue = false;
}
else {
e.stopPropagation();
e.preventDefault();
}
var id = this.args.id;
// do the rest

}

There are other ways as well but this seems the most flexible in
relevance of the arguments.
hi thanks for the reply
can u bit more specific
actually am tried am getting some errors at " with" if
commented popup not defined n
all,


see this code and try...........

function bG(catid)
{
//alert("showCategories()");
var catArray;
Org.getImmediateSubCategories(catid,{callback:func tion(cat) {
catArray = cat;
}, async:false});

var header=['','Category Name','Parent
Category','Description','Default Quantity'];
var grid=new OAT.Grid("ngrid_content",0,0);
grid.createHeader(header);
if (catArray.length > 0){
for(var i = 0;i < catArray.length;i++){
Org.getCategory(catArray[i],{callback:function(category){
var cb;
var name;
var parentId;
var parentName;
var parentName1;
var desc;
var fullQuantity=0;
var image;
var sr1;//src of image
var sr2;

id = category.id;
name="<a href = 'javascript:editCategoryDimmershow123("+id
+");'>"+category.name+"</a>"


parentId = category.parent;
fullQuantity =(category.quantity==""||category.quantity=="null" ||
category.quantity==null||
category.quantity==undefined)?"N.A":category.quant ity;
desc =(category.desc==""||category.desc=="null"||
category.desc==null||category.desc==undefined)?"N. A":category.desc;
//fullQuantity = category.quantity;
//desc = category.desc;
sr1 = category.image;
sr2 = "images/"+sr1;
//image='<image src="'+sr2+'" width="30px" height="30px" />';
cb = '<input type="checkbox" name ="cbs" id="cbs" value="'+id+'"/
Quote:
';
if(parentId != 0){
Org.getCategory(parentId,{callback:function(parent ){
parentName = parent.name;
var
rowArr=[cb,name,parentName,desc,fullQuantity];/////////////////////////
vp
grid.createRow(rowArr);
},asyn:true});
}else{
parentName = "Parent";
var rowArr=[cb,name,parentName,desc,fullQuantity];
grid.createRow(rowArr);
}


},asyn:false});
}
} else {
Org.getCategory(catid,{callback:function(category) {
var cb;
var name;
var parentId;
var parentName;
var parentName1;
var desc;
var fullQuantity=0;
var image;
var sr1;//src of image
var sr2;

id = category.id;
name="<a href ='#' onClick = 'javascript:editCategoryDimmershow("+id
+"); return false;'>"+category.name;+"</a>"
parentId = category.parent;
fullQuantity =(category.desc==""||category.desc=="null"||
category.desc==null||category.desc==undefined)?"N. A":category.desc;
desc =(category.desc==""||category.desc=="null"||
category.desc==null||category.desc==undefined)?"N. A":category.desc;
sr1 = category.image;
sr2 = "images/"+sr1;
//image='<image src="'+sr2+'" width="30px" height="30px" />';
cb = '<input type="checkbox" name ="cbs" id="cbs" value="'+id+'"/
Quote:
';
if(parentId != 0){
Org.getCategory(parentId,{callback:function(parent ){
parentName = parent.name;
var rowArr=[cb,name,parentName,desc,fullQuantity];
grid.createRow(rowArr);
},asyn:true});
}else{
parentName = "Parent";
var rowArr=[cb,name,parentName,desc,fullQuantity];
grid.createRow(rowArr);
}


},asyn:false});
}
}


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.