Shadowbox Plugin - Videos & Images in Lightbox

Posted by Vishal on September 24th, 2011

Recently I had to show Videos & Images in a Lightbox. A year back I had shown Videos with Lightbox using FancyBox, but that was not a very clean approach. So this time I decided not to use that & try something better.

I found out about Videobox. It is built only to show Videos in a lightbox. I tweaked it to also show images. It was working fine until I tested it in IE 8. Later I found out that this is an outdated lightbox application & the last known updated to it was in 2007. When I heard this, I abandoned it at that very moment.

The next I found was Shadowbox.js. The integration was very simple & at the same time, compatible across all browsers. It was up & running in 5 mins. Wow! Along with a free version, it also has a commercial license.

image setAttribute() does not work in IE 8

Posted by Vishal on September 22nd, 2011

Blogging after almost 10 months…Whew…long time!

Today I was trying to resolve an issue wherein an image was being displayed dynamically, but it wasn’t visible in it’s proper width & height only in IE 8.  The height & width were being set by:

img.setAttribute(”width”,”50px”);

img.setAttribute(”height”,”50px”);

It didn’t take much time to resolve this issue. The issue was that IE 8 (Not sure of other versions) didn’t like the above method of setting the width & height. Instead, I had to use the below:

img.style.width = “50px”;

img.style.height = “50px”;

This worked like a charm in all browsers.

“Unknown runtime error” in IE8 while using ajax

Posted by Vishal on November 24th, 2010

Problems with Internet Explorer don’t seem to have an end…Recently I came across a few problems while using IE 6 & a few friends told me to “Screw that” and move on to IE 8 as it is much like Firefox with an inbuilt debugging tool & ofcourse with lesser issues than IE 6. Trusting them, I did move to IE 8.

But one problem that was persistent across both IE 6 & IE 8 was a simple AJAX functionality that used to work in Firefox but not in IE 6 or IE 8.

I discovered that the AJAX call was working fine & the response was also being returned same in both browsers, but the issue was while updating the element after getting the response. The element in question here was a table i.e. I had code like:

<table id=’id_to_update’>

It was giving me an error “Unknown runtime error”.

I was trying to find a solution to this & found quite a few options like changing the case of XMLHTTP to XMLHttp, of trying to create an ActiveXObject before creating an XMLHTTP object. I tried all that, but didn’t work. Later I found that in IE, it is not possible to update a ‘table’ content through ‘innerHTML’. It worked only after I put the table inside a ‘div’, so the code was:

<div id=’id_to_update’>

<table>….</table>

Where the “<table>, </table>” part was the one that was being updated through AJAX.

Change button ‘type’ for dynamic buttons in IE using Javascript

Posted by Vishal on November 21st, 2010

Recently I was working on a piece of code where the requirement was to create buttons dynamically on click of another link/button. The code was:

var button1=document.createElement(’INPUT’);
button1.name =’button1_name’;
button1.setAttribute(”type”,”button”);
button1.setAttribute(”id”,”button1_id”);
button1.setAttribute(”value”,”Submit”);

The above code was working perfect in Firefox. However, in IE 6, this code did not create a button. It simply didn’t work! While trying to find a solution, I came across a link that said while creating dynamic buttons through Javascript, the ‘type’ attribute can’t be set dynamically using setAttribute() in IE 6. What needed in IE 6 was:

var button1=document.createElement(’<input type=”button” name=”button1_name” />’);

The above code will also work for Firefox, thus to make it cross-browser, had to hard-code the tag as written above.

‘Object Expected’ error in IE 6

Posted by Vishal on November 20th, 2010

I was getting this strange error when I was trying to write a function as simple as asking for confirmation while deleting a particular record. On click of the ‘Delete’ link, it used to give me this error “Object Expected” in IE 6.

The code that I had written before the error was like:

<script language=”javascript” type=” text/javascript”>
function deleteConfirmation(id)
{
var answer = confirm(”Are you sure you wish to delete this entry?”);

if (answer){
location.href = ’some url’;
}
else{
return false;
}
}
</script>

In the first glance, I am not sure how many of you will be able to point out what the error is. The code after correcting this error looks like:

<script language=”javascript” type=”text/javascript”>
function deleteConfirmation(id)
{
var answer = confirm(”Are you sure you wish to delete this entry?”);

if (answer){
location.href = ’some url’;
}
else{
return false;
}
}
</script>

Well, the difference between the two pieces of code lies in the first line:

<script language=”javascript” type=”text/javascript”>

The error was occurring as there was a space preceding in the value given in the ‘type’ attribute. I removed the extra space before “text/javascript” and that’s all what it took to resolve this error. Oh yes, this error was occurring only in IE 6 & not in Firefox.

Show table row (tr) using css

Posted by Vishal on November 4th, 2010

I was working on a piece of code in which I needed to hide a row (’tr’) on click of a link & show it again on a similar event. Tried to achieve that using the usual display:none & display:block methods.

That method gave me problems across browsers. Then I read somewhere that to show a tr using css, we could use:

style.display = ‘table-row’

This worked, but not across all browsers. Finally read somewhere that if we use:

style.display = ”

This would make the browser take the default values whether it’s table-row or display:block. This one worked for both IE & Firefox.

setcookie() - able to set cookies but not access through $_COOKIE

Posted by Vishal on August 14th, 2010

Came across a strange problem today. I was setting a few cookies using the setcookie() and when trying to access them through $_COOKIE, they weren’t appearing in the array. The cookie is shown in browser but not accessible in $_COOKIE. Initially, I was just using:

setcookie(”cookie_name”,$cookie_value);

My script was residing in a folder ‘/abc’ on the server, which is present in the document root. Then I had to change the above to:

setcookie(”cookie_name”,$cookie_value, time()+(86400*365), “/”, “.example.com”, 1);

I put in the expiry date as 1 year from today, put in the path of the document root i.e. ‘/’ & also made the cookie to be available on all subdomains on my main domain (by using a .) rather than only on www.

The above line also didn’t solve the problem. Finally, I turned the last argument from ‘1′ to ‘0′. It specifies that the cookie will not be accessible by any scripting language & hence PHP was unable to access the cookie, though it was appearing in the browser cookies. What solved the problem was:

setcookie(”cookie_name”,$cookie_value, time()+(86400*365), “/”, “.example.com”, 0);

Hope this helps. :)

Twitter Weekly Updates for 2010-04-04

Posted by Vishal on April 4th, 2010

Powered by Twitter Tools.

SHTML Wrapper - 500 Server Error

Posted by Vishal on January 6th, 2010

I was getting the above error when I moved my Magento installation from one host to Bluehost (Hostmonster). What I used to get was nothing on the screen with the error:

<!– SHTML Wrapper - 500 Server Error –>

appearing in the source of the page.

I tried various things like reinstalling the database, reinstalling Magento, tried to see the logs I had access to. None of them worked.

Then I came across a link that said enabling FastCGI option for PHP would fix this. That’s exactly what I did & the bug was fixed. The Magento installation then started working smoothly.

Strangely, I had come across a link that said disabling FastCGI will fix this, but that wasn’t the case.

Twitter Weekly Updates for 2009-10-25

Posted by Vishal on October 25th, 2009
  • Explaining what twitter is to a friend… #

Powered by Twitter Tools.


Copyright © 2007 Vishal Kothari. All rights reserved.