views:

111

answers:

4
+1  Q: 

Object required

function OnImageClick ()
{
  var url;
  switch (picNumber) {
  case 0:
   url = "http://www.zagreb.in/horoskop/rak.html";
   break;
  case 1:
   url = "http://www.zagreb.in/horoskop/ovan.html";
   break; <-- error
  case 2:
   url = "http://www.zagreb.in/horoskop/djevica.html";
   break;
  case 3:
   url = "http://www.zagreb.in/horoskop/vaga.html";
   break;

Hi, I have problem IE, error is Object required on line 55 and it is the second break; Can you help me, Regards

Alen

A: 

It's hard to tell where the error comes from. Try enabling your ie debugger first so that you can catch the exact location of the error and post back your findings so that we can help.

Enabling debugger for IE:

  1. Open IE
  2. Click Tools->Internet Options->Advanced
  3. Under Browsing category, uncheck "Disable script debugging(Internet Explorer)" option. Run your program and the ie debugger will appear when it encounters a problem.
junmats
+1  A: 

Where did you get that picNumber? Is it global? If not, maybe that throws the error because it is not initialized.

junmats
A: 

I believe that object error happens only because you are not passed the value to this function. it should be like bellow,

<img src="test.jpg" onclick="javascript:OnImageClick(this.id);" id="1" />

function OnImageClick (picNumber)
{
   var url;
  switch (picNumber) {
  case 0:
   url = "http://www.zagreb.in/horoskop/rak.html";
   break;
  case 1:
   url = "http://www.zagreb.in/horoskop/ovan.html";
   break; <-- error
  case 2:
   url = "http://www.zagreb.in/horoskop/djevica.html";
   break;
  case 3:
   url = "http://www.zagreb.in/horoskop/vaga.html";
   break;


}
tummy.developer
A: 

Remove the <-- error

powtac