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. :)

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.

Facebook apps - Are they spamming?

Posted by Vishal on September 16th, 2009

Facebook

I have been playing with Facebook recently & trying out different apps. I thought I would just write down my reviews for each of the apps I tried & share some views as well.

Applications tried so far:

  1. What does your day of the birth say?
    1. Asks to enter birth date – doesn’t have it pre-populated from Facebook
    2. Says something about the day I was born like: Adventurous, Great sense of humor, Loves to enjoy life, etc.
    3. Has ads of other apps
    4. My Review: Not exciting.
  2. Magic Fortune Cookie
    1. Simply flashes a line of text that says what I am going to do today or in the near future. Also has some numbers being displayed.
    2. Has ads of other apps & other external ads also
    3. My Review: Just shows randomly things you might do, but unreal. Not exciting, except for the things that it shows.
  3. Love personality test
    1. Has a questionnaire of around 8 to 10 questions. Based on that, gives the result.
    2. My Review: Didn’t complete this. I think I hate apps that answer more than 4-5 questions. :)
  4. How sexy is your name?
    1. Asks to add up certain numbers associated with letters in your name. Based on the sum, it determines whether your name is sexy or not.
    2. Has external ads & ads of other apps like ‘Find out your top follower’.
    3. My Review: Didn’t complete this one too. I think it’s something unreal & I found it to be a waste of time to sit & add the numbers associated with my alphabets to tell me how sexy is my name. :)
  5. Farmville - Game
    1. Provides the user with a farm. Allows user to plough, harvest, etc. After ploughing a crop, asks the user to come after a particular time (time taken by the crop to grow). This way, user keeps coming back again & again.
    2. My Review: This is one of the popular games on Facebook. I hate the idea of going back again & again when my crop is fully grown & then harvest.
  6. Think fast challenge
    1. Directly asks for Name, email & mobile number on the first page of the application itself. A good way to collect email addresses. But even after I entered my correct number, it said “Please Enter Valid Mobile No.” J
    2. My Review: It said it will ask 200 questions which we need to answer in 60 seconds. But they didn’t let me go off the first page itself where they kept asking for my mobile number despite providing it correct 3-4 times. I am not sure what the questions would be, but this app is definitely not something which it says it is, people won’t sit & answer 200 questions…
  7. Death’s time
    1. Simply populates your birth date from Facebook by default & asks you to Submit. After hitting Submit, gives a random day of death along with a random cause.
    2. My Review: This app catches your attention once you see it on your WALL. Same happened with me. I went to the app, it had my birthday pre-populated from Facebook. All I had to do was click ‘Submit’ & it showed me randomly what my death time & reason was. I am going to heaven in 2014 :)
  8. What do your friends think about you?
    1. Asks to choose 4 friends from your friend list. Wasn’t able to complete this one as I couldn’t really understand what this app was doing. J
    2. My Review: Refer to ‘a’ :)
  9. Are you going to heaven or hell?
    1. Another quiz type app which asks questions whether you believe in God, whether you forgive your enemy, etc. And of course, you go to heaven or hell based on your answers to those 5-6 questions.
    2. My Review: Found this one to be an average app. Not exciting, but since they kept it to 5-6 questions, I took it & the options have been formed well too.

After reviewing all the above apps, what I found was 80% of the apps have either external ads or have ads of other Facebook apps on them. The first thing that came to my mind was: Is this spamming of applications? I think yes.

There are way too many meaningless apps or apps that simply seem to be have made to host other ads & have more clicks. I am not sure if that is acceptable under Facebook terms or not.

Facebook is definitely changing the way people interact & changing it in a big way.

Google vs Facebook

Posted by Vishal on June 28th, 2009

Most of you would be unaware, but there is a fierce competition going on between Google and Facebook to establish their competing visions for the future of the internet.

For the last decade or so, the Web has been defined by Google’s algorithms — rigorous and efficient equations that parse practically every byte of online activity to build a dispassionate atlas of the online world.

Facebook CEO Mark Zuckerberg envisions a more personalized, humanized Web, where our network of friends, colleagues, peers, and family is our primary source of information, just as it is offline. In Zuckerberg’s vision, users will query this ’social graph’ to find a doctor, the best camera, or someone to hire — rather than tapping the cold mathematics of a Google search.

It is a complete rethinking of how we navigate the online world, one that places Facebook right at the center. In other words, right where Google is now.

A related article at ReadWriteWeb suggests that while Facebook’s member base is enormous, the company hasn’t taken advantage of its influence as well as it should have, though the capability for it to do so still exists.


Copyright © 2007 Vishal Kothari. All rights reserved.