Bug 27988

Summary: Assigning functions to javascript events does not work
Product: [Applications] konqueror Reporter: djoham
Component: kjsAssignee: Konqueror Developers <konq-bugs>
Status: CLOSED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:

Description djoham 2001-07-01 22:03:26 UTC
(*** This bug was imported into bugs.kde.org ***)

Package:           kjs
Version:           KDE 2.2.0 CVS/CVSup/Snapshot
Severity:          normal
Installed from:    Compiled sources
Compiler:          GCC 2.96
OS:                Linux
OS/Compiler notes: Not Specified


This bug may be related to bug 20165 but I can't really reproduce what he was trying to say so I'm logging this myself.

I'm using KDE from 30 June CVS

I'm trying to get HeirMenus from DHTML labs working in Konqi. These are the most popular javascript menus on the web to my knowledge. There seem to be a lot of problems with Konqi so I'm going to log the bugs one at a time.

The issue with this bug is that Konqueror will not allow you to set a custom function for window.onload. The following HTML will show an alert box in Mozilla NN4 and IE

<html>
<body>
<form>
when working properly an alert box that says "hello world" should pop up
</form>
</body>
</html>
<script language="javascript">
window.onload = function(){showAlert()};

function showAlert() {
        alert("hello world");
}


</script>

the error that is reported by Konqi from the output is: "JavaScript parse error at line 1."

This is how the javascript menus get started. Without support for this function no menus are ever created.

I've worked around this bug for now so that I can continue testing but in order to support those menus we'll need to fix this problem.

If we can fix this problem it will go a long way towards geting rid of many of the annoying "javascript menus not working" bugs that we recieve...

If you need further information please contact me at djoham@yahoo.com

David

(Submitted via bugs.kde.org)
(Called from KBugReport dialog. Fields Application KDE Version OS Compiler manually changed)
Comment 1 djoham 2001-07-02 05:44:44 UTC
I've investigated further and found another similar
bug that's close enough to be placed here. Let me know
if you would like to have this in its own bug...

It looks like Konqi won't let you set any of the even
handlers for elements native events. The menus create
a new div and then assign onclick onmouseover and
onmouseout events to handle mouse input. Konqi seems
to ignore these assignments. Run the following code in
Mozilla. It works as expected. Konqi creates the DIV
but then does nothing else...

<html>
<body>
<form>
</form>
<input type="button" id="button" value="createDiv"
onclick="createDiv()">
</body>
</html>

<script language="javascript">

function createDiv() {
        var x = document.createElement("DIV");
        x.id = "newDiv";
        x.style.position = "absolute";
        x.style.height = "200px";
        x.style.width =  "200px";
        x.style.top = "200px";
        x.style.left = "200px";
        x.style.backgroundColor = "red";
        x.innerHTML = "hello";
        x.onclick = charlie;
        x.onmouseover = mouseOver;
        x.onmouseout = mouseOut;
        document.body.appendChild(x);
        document.getElementById("button").disabled =
true;
}

function charlie() {
        alert("Hi I'm charlie");
}

function mouseOver() {
       
document.getElementById("newDiv").style.backgroundColor
= "blue";
}

function mouseOut() {
       
document.getElementById("newDiv").style.backgroundColor
= "red";
}


</script>


Thanks. Please let me know if there is anything else I
can do to help.

David

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/
Comment 2 Harri Porten 2002-03-03 13:55:35 UTC
Works now. Added the two testcases to our repository btw.