I'm using MooTools (www.mootools.net) javascript library for a drop
down navigation in my website. I also use SWFObject to insert Flash
elements throughout my page.
This, so far, works fine.
But the moment I click on a link in the navigation (which directs to a
new page), I get an error message appear before the page url changes.
I don't understand why this happens but I can't put the site live
until I resolve the issue?
The error is "Object doesn't support this method or property"?
Obviously Firefox and Safari don't have any problem with the page.
Any help would be appreciated!
Kind regards,
Mark
My code is as follows (I've removed irrelevant code)....
<script src="/Assets/Scripts/domready.js" type="text/javascript"></
script>
<script src="/Assets/Scripts/contact.js" type="text/javascript"></
script>
<script src="/Assets/Scripts/latest.js" type="text/javascript"></
script>
<script src="/Assets/Scripts/mootools.js" type="text/javascript"></
script>
<script src="/Assets/Scripts/swfobject.js" type="text/javascript"></
script>
<script src="/Assets/Scripts/swfobject-settings.js" type="text/
javascript"></script>
<script type="text/javascript">
window.addEvent('domready', function()
{
// Create each slide object
var whatWeDo = new Fx.Slide('ddWhat');
var whoWeDoItFor = new Fx.Slide('ddWho');
var archive = new Fx.Slide('ddArchive');
// Hide the drop down menus
whatWeDo.hide();
whoWeDoItFor.hide();
archive.hide();
// Add extra spacing to drop down lists
$('ddWhat').style.paddingBottom = "3px";
$('ddWho').style.paddingBottom = "3px";
$('ddArchive').style.paddingBottom = "3px";
// Add a cursor styles to the drop down headers
$('toggleWhat').style.cursor = "pointer";
$('toggleWho').style.cursor = "pointer";
$('toggleArchive').style.cursor = "pointer";
The problem lies in the script file "<script src="/Assets/Scripts/
swfobject-settings.js" type="text/javascript"></script>" because
whenever I remove this script and click on a link then the page
changes fine without triggering an error?
var flashvars = {};
var latestflashvars = {};
latestflashvars.date = "31/02/09";
var paramsHeader = {};
paramsHeader.menu = "false";
paramsHeader.wmode = "transparent";
var attributes5 = {};
attributes5.id = "flashlatest1";
var attributes6 = {};
attributes6.id = "flashlatest2";
var attributes7 = {};
attributes7.id = "flashlatest3";
var attributes8 = {};
attributes8.id = "latesthome";
var attributes9 = {};
attributes9.id = "sub-header";
// Check if elements are available to replace
addDOMLoadEvent(insertFlash);
function insertFlash()
{
if(document.getElementById("flash") != null)
{
swfobject.embedSWF("/Assets/Flash/Header.swf", "flash", "750",
"295", "9.0.0", "/Assets/Flash/expressInstall.swf", flashvars,
paramsHeader, attributes1);
}
Although this may seems stupid - I've always been able to solve this
issue by making any JS calls at the end of the page when all elements
have been loaded.
I would check to make sure that the order in which your elements are
loaded doesn't allow one to be loaded after the actual call.
If you'd be kind enough to load it all on a temp area, perhaps i can
have a look at it, although I'm far from a Javascript guru, I've made
a couple of mistakes that allowed me to find some good solutions.
On May 16, 10:05 am, Mark <storm.m...@googlemail.com> wrote:
> The problem lies in the script file "<script src="/Assets/Scripts/
> swfobject-settings.js" type="text/javascript"></script>" because
> whenever I remove this script and click on a link then the page
> changes fine without triggering an error?
> var flashvars = {};
> var latestflashvars = {};
> latestflashvars.date = "31/02/09";
embedSWF fires on a SWFObject internal DomContentLoaded event. When
you use an other script that calls these functions on the same event
you can figure that this will probably never be fired. So if you get
rid of constructs like:
addDOMLoadEvent(insertFlash);
function insertFlash()
{
if(document.getElementById("flash") != null)
Thanks for the information, but I need to use the if statements...
e.g.
if(document.getElementById("the-element-to-be-replaced") != null)
...to check if the element I'm looking to replace is available or not
and to use the if statement requires me to use a onDomLoaded style
event otherwise the script runs before the relevant html element is
available in the dom to check against.
I commented out all my code and tested using just the
swfobject.embedSWF() for an element I know exists on all pages (just
to see if this odd error disappeared) but the error still came up the
moment I clicked a link to move to another page in my website?
Here is a link to the online version, you can see (if your internet
explorer is setup to show all errors) the problem when you use the
side navigation to click around other pages....
if you need to use your own domready script, you can use
swfobject.createSWF(attObj, parObj, replaceElemIdStr) to embed the SWF
without using SWFObject's addDomLoadEvent function.
From what I see of your code, you have three different domready-style
scripts in your page:
mootools: window.addEvent("domready", function);
swfobject: swfobject.addDomLoadEvent(fn)
and your own addDOMLoadEvent(insertFlash);
this is redundant and could lead to errors. if you're sticking with
mootools, get rid of the addDOMLoadEvent(insertFlash) function and
just use window.addEvent("domready", insertFlash);
> Here is a link to the online version, you can see (if your internet
> explorer is setup to show all errors) the problem when you use the
> side navigation to click around other pages....