PDA

View Full Version : Javascript error while in Dreamweaver


quintain
03-22-2005, 04:56 PM
Hi
I use dreamweaver MX 2004 ver 7.0
I have just registered because I have just started to recieve the following error message/s when I copy/paste and I do not know why, (possibly something I have inadvertantly hit?)

Error Message (I have copied exactly including correct case)
While executing onload in PasteFireworksHTML.htm, the following javascript error/s occurred;
In File ""PasteFireworksHTML"";
ReferenceError; initialize is not defined

The message requires me to click OK it then displays the same message again and upon clicking OK I can paste.
It happens every time I paste; I.E even when pasting the same item repeatedly.

On investigating I discover that I have the file PasteFireworksHTML.htm within programme files/dreamweaver mx/configuration/commands. it is 3kb and last modified 05/09/2003 BUT I have just started to get the above error message even though I have been using the programme and copy/paste all the time.

Can anyone help please.
Regards, Quintain

ranjan
03-22-2005, 10:26 PM
I am glad you found the file causing the error.

Here is what you do

Open the file 'PasteFireworksHTML.htm' In NOTEPAD. Copy its contents and post the contents here. Following this I can go through the file to locate the error

quintain
03-22-2005, 11:21 PM
Hi Ranjan
Thank you for your offer of assistance.
I show below the code but I am intriqued as to why the error has just started.
I have been using MX for 12 month (a long time but on very infrequent occasions and never has there been the time to devote to learning the programme and web design/writing has never been a natural occurance for me)

<!-- MENU-LOCATION=NONE -->
<head>
<script language="JavaScript" src="PasteFireworksHTML.js"></script>
<script language="JavaScript" src="../Shared/Common/Scripts/dwscripts.js"></script>
<script language="JavaScript" src="../Shared/MM/Scripts/Class/FileClass.js"></script>
<script language="JavaScript" src="../Shared/MM/Scripts/CMN/string.js"></script>
<script language="JavaScript" src="../Shared/MM/Scripts/insertFireworksHTML.js"></script>
<script language="JavaScript">
// Copyright 2000, 2001, 2002, 2003 Macromedia, Inc. All rights reserved.

//--------------- LOCALIZEABLE GLOBALS---------------

var LABEL_selectFolder = "Copy image files to";

var MSG_notExportedForDW =
"The Fireworks HTML you are trying to insert is not the correct format.\n" +
"Please re-export your HTML from Fireworks using the Dreamweaver style.";
var MSG_behNotSupported =
"The Fireworks HTML you are trying to insert contains JavaScript\n"+
"functions that are not supported by Dreamweaver.\n" +
"Please insert your HTML manually to ensure proper functionality.";

var MSG_folderNotUnderSite =
"The folder you have selected is not under the site root.\n\n" +
"Your root folder is:\n%s\n\n" +
"Please select a folder within the site.";

var MSG_docUnsaved =
"In order to generate correct references to files that you are\n" +
"importing, you must save your document.\n\n" +
"Click OK to save the document now, or Cancel to continue without\n" +
"saving.";

/*
var MSG_copyFilesToSite =
"Some referenced files are outside of the root folder of site '%s'\n" +
"and may not be accessible when you publish the site.\n\n" +
"The referenced files are:\n%s\n\n" +
"Your root folder is:\n%s\n\n" +
"Copy these files into site?";
var MSG_overwriteFiles =
"Some files being copied already exist in the selected folder.\n\n" +
"The existing files are:\n%s\n\n" +
"Do you want to replace the existing files?";
*/

var MSG_copyFailed =
"Some files could not be copied to the selected folder.\n\n" +
"The files not copied are:\n%s";


// Shorter versions which work on the Mac
var MSG_copyFilesToSite =
"Inserting Fireworks HTML...\n\n" +
"Some referenced files are outside of the root folder of site '%s'\n" +
"and may not be accessible when you publish the site.\n\n" +
"Copy these files into site?";
var MSG_overwriteFiles =
"Some files being copied already exist in the selected folder.\n\n" +
"Do you want to replace the existing files?";

//--------------- END LOCALIZEABLE ---------------
//--------------- END JAVASCRIPT ---------------
</script>
<link href="../fields.css" rel="stylesheet" type="text/css">
</head>
<body onLoad="initialize()">
</body>

I hope you can help
Best Regards, Quintain

ranjan
03-23-2005, 05:00 AM
The htm file has no errors

Please follow instruction as per my prior post and post the code of file 'PasteFireworksHTML.js' here.

It cold happen if your computer crashed with dreamweaver open corrupting the file in process or maybe while installing a new extension.

Is there a way i can send you the 2 files zipped for you to unzip in commands directory?

quintain
03-23-2005, 09:48 PM
Hi Ranjan
Sorry for the delay, I show below the .js file, would it help if I sent the page file for the (amateur) site I am developing where the problem exists (or even published it and sent you the link.
Also a new error message popped up as I was closing DW MX down, again it repeated itself twice.

Error message
While executing onload in Teamadmintempdelete.html, the following javascript error/s occurred;
In file ""TeamadminTempDelete"",Reference error; delTempFile is not defined

// Copyright 2000, 2001, 2002, 2003 Macromedia, Inc. All rights reserved.

//*************** GLOBALS *****************

var USE_SITE_RELATIVE = false;


//******************* LOCAL FUNCTIONS **********************

function isDOMRequired() {
// Return false, indicating that this object is available in code view.
// This will prevent the document from syncing with design view on every
// paste in code view. This command actually does require that the DOM
// be synchronized, but we'll postpone that until we're sure that we're
// actually pasting Fireworks HTML.
return false;
}

function initialize() {
var validFWFile = false;
var fwSource = dw.getClipboardText();
if (fwSource && isFireworksHTML(fwSource)) {
validFWFile = true;
MM.event.handled = pasteFWHTML();
}else{
MM.event.handled = false;
}
}


function pasteFWHTML() {
var result, validFWFile=false;
var fwURL, fwSource, fwDOM;
var docURL, docDOM, siteURL, parentFile, docRootURL, siteRootURL;

// Force a sync... we have postponed this until we are certain that we're
// actually pasting Fireworks HTML.
if (!dw.getDocumentDOM().isDesignViewUpdated())
dw.getDocumentDOM().synchronizeDocument();

fwSource = dw.getClipboardText();

if (fwSource && isFireworksHTML(fwSource)) {
validFWFile = true;
if (!isDWStyle(fwSource))
alert(MSG_notExportedForDW);
else if (!usesDWBehaviors(fwSource))
alert(MSG_behNotSupported);
}

if (validFWFile) {
fwURL = dw.getConfigurationPath() + "/Shared/MM/Cache/empty.htm";
DWfile.write(fwURL,'');
fwDOM = dw.getDocumentDOM(fwURL);

//for i18n, we need to make sure the fwDOM matches the encoding of the users dom
fwDOM.setCharSet( dw.getDocumentDOM('document').getCharSet() );

// remove Content-Type metas from fwSource before sticking source in fwDOM
// (there should already be a meta in Dreamweaver, so removing this one will
// prevent a duplicate meta being added).
fwSource = fwSource.replace(/<meta\s+http-equiv="Content-Type[^>]*>[\r\n\s]*/i,'');

fwDOM.documentElement.outerHTML = fwSource;

docURL = dw.getDocumentPath("document");
siteURL = dw.getSiteRoot();

docRootURL = '';
siteRootURL = '';
if (docURL) {
parentFile = new File(docURL);
docRootURL = parentFile.getAbsoluteParent() + File.separator;
if (USE_SITE_RELATIVE) {
parentFile = new File(siteURL);
siteRootURL = parentFile.getAbsolutePath();
}
}

docDOM = dw.getDocumentDOM('document');

// The Insert FWHTML Object fixes up the caret to make sure it's
// in the body before inserting the HTML returned by insertFireworksHTML.
// Paste doesn't do this, so we're going to do it manually. We
// start by checking to make sure the IP is in the body. If it isn't,
// we move it to the body.
if (!dwscripts.isInsideTag(docDOM.getSelectedNode(),"BODY")){
var bodyNode = docDOM.body;
var bodyOffsets = docDOM.nodeToOffsets(bodyNode);
docDOM.setSelection(bodyOffsets[1]+1,bodyOffsets[1]+1);
}

// Next we save the current selection relative to the body tag.
saveBodyRelativeSelection();

theHTML = insertFireworksHTML(fwDOM, fwURL, docRootURL, siteRootURL);

// We're done with the fwDOM. Release it.
dw.releaseDocument(fwDOM);

// Now restore the selection to the body before doing the insert.
restoreBodyRelativeSelection();
docDOM.insertHTML(theHTML, true);
}

return validFWFile;
}

// These functions were copied from Objects/Server/serverObjectsCommon.js
// because it didn't make sense to include that file here.
//
//--------------------------------------------------------------------
// FUNCTION:
// saveBodyRelativeSelection
//
// DESCRIPTION:
// Stores the body tag relative location of the current selection
// in the global variable CURRENT_SEL.
//
// ARGUMENTS:
// none
//
// RETURNS:
// nothing
//--------------------------------------------------------------------

var CURRENT_SEL = null;

function saveBodyRelativeSelection()
{
var dom = dw.getDocumentDOM();

var sel = dom.getSelection();

if (sel && sel.length > 1)
{
var bodyOffset = dom.nodeToOffsets(dom.body);

sel[0] = sel[0] - bodyOffset[0];
sel[1] = sel[1] - bodyOffset[0];

CURRENT_SEL = sel;
}
}


//--------------------------------------------------------------------
// FUNCTION:
// restoreBodyRelativeSelection
//
// DESCRIPTION:
// Sets the selection back to its original location, before any
// head edits were made.
//
// ARGUMENTS:
// none
//
// RETURNS:
// nothing
//--------------------------------------------------------------------

function restoreBodyRelativeSelection()
{
var sel = CURRENT_SEL;
CURRENT_SEL = null;

if (sel)
{
var dom = dw.getDocumentDOM();

var bodyOffset = dom.nodeToOffsets(dom.body);

sel[0] = sel[0] + bodyOffset[0];
sel[1] = sel[1] + bodyOffset[0];

dom.setSelection(sel[0], sel[1]);
}
}

ranjan
03-23-2005, 10:58 PM
Both the js and htm files are fine.

The problem lies else where. This is now more obvios because of the new error.

I would recommend one of the following

1. Install 7.0.1 Updater ('http://www.macromedia.com/support/dreamweaver/downloads_updaters.html')

2. A fresh dreamweaver install.

If you need to back up your sites/extensions etc before reinstalling dreamweaver, I would recommend MM Exporter ('http://mm-exporter.joexx.de/')

quintain
03-24-2005, 04:09 PM
Ranjan
Thanks for all of your help, I appreciate the time you have spent on my behalf.
I will probably try a fressh instal.
Best Regards, Quintain