The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Javascript not activating in IE
DeaPeaJay
post Sep 26 2007, 08:02 PM
Post #1


Advanced Member
****

Group: Members
Posts: 103
Joined: 21-September 06
From: East Tennessee - USA
Member No.: 191



I've got this page http://www.exit42design.com/development/ex...scrapbook2.html

and when it loads it's supposed to work some javascript. But it never does in IE7 (not worrying about 6). I tried manually calling the function, but it gives me an error and it says "Object Expected" I don't know what that wants me to do.

In my playing around trying to fix it, if I don't get that error I'll get one that says Syntax error.

I must be missing something obvious but I don't know what it is.

This post has been edited by DeaPeaJay: Sep 26 2007, 08:08 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Sep 27 2007, 12:25 AM
Post #2


Jocular coder
********

Group: Members
Posts: 2,460
Joined: 31-August 06
Member No.: 43



It's not obvious that you're missing something obvious - why should you think that?

You're using a script that's using a fancy function to add an onload event:

//cool page loading function by Simon Willison http://simonwillison.net/2004/May/26/addLoadEvent/
function addLoadEvent(func) {

... but since you know you only have this one onload event it might be more reliable to add it directly to the <body> tag (onload=...), since "cool" functions have a way of being fragile, particularly with things like IE...
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Frederiek
post Sep 27 2007, 02:51 AM
Post #3


Programming Fanatic
********

Group: Members
Posts: 5,146
Joined: 23-August 06
From: Europe
Member No.: 9



In Safari, I get a javascript parse error on line 2 of your script upon opening the page:
const FRAME_NAME = "frame_scrapbook";

What's "const"?

Change it to var FRAME_NAME = "frame_scrapbook"; and see what happens.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
DeaPeaJay
post Sep 27 2007, 07:16 AM
Post #4


Advanced Member
****

Group: Members
Posts: 103
Joined: 21-September 06
From: East Tennessee - USA
Member No.: 191



QUOTE(Brian Chandler @ Sep 27 2007, 01:25 AM) *

It's not obvious that you're missing something obvious - why should you think that?

You're using a script that's using a fancy function to add an onload event:

//cool page loading function by Simon Willison http://simonwillison.net/2004/May/26/addLoadEvent/
function addLoadEvent(func) {

... but since you know you only have this one onload event it might be more reliable to add it directly to the <body> tag (onload=...), since "cool" functions have a way of being fragile, particularly with things like IE...


Well I figured that function wasn't the problem since I couldn't activate the script manually either.


QUOTE(Frederiek @ Sep 27 2007, 03:51 AM) *

Change it to var FRAME_NAME = "frame_scrapbook"; and see what happens.



Thanks!, that fixed it. I read somewhere that that was how to declare a constant in javascript, I guess not.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
DeaPeaJay
post Sep 27 2007, 12:16 PM
Post #5


Advanced Member
****

Group: Members
Posts: 103
Joined: 21-September 06
From: East Tennessee - USA
Member No.: 191



On a related note. I've got a fundamental flaw with the code that I'm using to insert extra elements into the HTML. I'm using the insertBefore method, but what that does is place the code immediately before the parent element's closing tag. But what if I wanted to insert the code somewhere in the middle of the parent element and not immediately before it closes.

For example, if I wanted to insert code in the middle of a paragraph of text

CODE

<div>

<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

insert it here

<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

instead of here
</p>


Is this possible? I can't figure out how to identify the *exact* spot I want.

This post has been edited by DeaPeaJay: Sep 27 2007, 12:16 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Sep 27 2007, 05:44 PM
Post #6


.
********

Group: WDG Moderators
Posts: 9,661
Joined: 10-August 06
Member No.: 7



You must identify the element you want to insert it before. This can be done in a number of ways, see e.g. http://www.quirksmode.org/dom/intro.html and the very useful http://www.quirksmode.org/dom/w3c_core.html
User is online!PM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 27th April 2024 - 08:35 AM