Author Topic: javascript interaction within a html form  (Read 1185 times)

Teko

  • Newbie
  • *
  • Posts: 9
javascript interaction within a html form
« on: August 31, 2009, 08:53:00 AM »
Hi all,

Having some problems when trying to use javascript interation with the megazine which is nested within a HTML form. I was thinking along the lines that the megazine.js file would need updating to handle the Form ID when getting the reference to the megazine flash object but havent been able to make it work.

Any suggestions?

Thanks,

Teko

  • Newbie
  • *
  • Posts: 9
Re: javascript interaction within a html form
« Reply #1 on: September 01, 2009, 06:43:25 AM »
Hi all,

Got this to work cross browser by changing the getMovie: function() call in megazine.js to use getElementById like this

Code: [Select]

getMovie: function() {
    var formRef = document.getElementById([MegaZine.moviename]);
        return formRef;
    },


Feel free to let me know if you see any limitations with this.

Thanks!

kongo09

  • Jr. Member
  • **
  • Posts: 39
Re: javascript interaction within a html form
« Reply #2 on: January 30, 2010, 06:51:40 PM »
This is an interesting finding. I have a different problem but potentially the same solution applies.

The Problem

Using some DOM modifying Ajax calls, I remove the book from the document, rebuild it on the server and then put it back on the document. Essentially a reload of everything  ;) Unfortunately, on the way the reference to the object seems to get lost somewhere in the DOM for Internet Explorer. Works fine on FireFox.

The getMovie function always returns NULL and InternetExplorer breaks with a JavaScript error of:

Quote
Microsoft JScript runtime error: 'Megazine.getMovie()' is null or not an object

The book displays, but I can't access it from the outside anymore.

The (potential) Solution

Using the Microsoft Script Editor, I found that window[MegaZine.moviename] does indeed not resolve. Typing a watch expression for document.getElementByName(MegaZine.moviename) returned an object.

Unfortunately, I can't edit the code right now to test if that works, but it seems to go along the lines of what has been posted above in this thread. I'll report back.

Question

Is there any special reason why getElementByName is not used by MegaZine?

Cheers,
kongo09

kongo09

  • Jr. Member
  • **
  • Posts: 39
Re: javascript interaction within a html form
« Reply #3 on: January 31, 2010, 02:05:09 PM »
As my post relates to version 2.x, I'm continuing this thread here: http://megazine.mightypirates.de/forum/index.php/topic,890.0.html to avoid cross-posting.

Hans Nücke

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 454
  • MegaZine3 Sales Manager
Re: javascript interaction within a html form
« Reply #4 on: January 31, 2010, 04:52:15 PM »
Thanks  :D

Florian Nücke

  • κρύα πόδια
  • Administrator
  • Hero Member
  • *****
  • Posts: 1413
  • MegaZine3 Developer
    • MegaZine3
Re: javascript interaction within a html form
« Reply #5 on: February 01, 2010, 08:15:44 PM »
Is there any special reason why getElementByName is not used by MegaZine?

Because that's how I found it in the examples published by Adobe :P
Will test your approach (which appears cleaner indeed) and change it for future releases accordingly if there are no problems (i.e. in other browsers like Opera and Safari... wouldn't be the first time -.-) Thanks.
For the Snark was a Boojum, you see.

Before you ask a question
          After you get an answer
  • please document your problem with the answer in the Project Wiki. (e.g. in the FAQs)
  • help others out if you can, by answering their questions on the forum.