overlay div pop up not working in google chrome

Okay, here is the issue and solution

Problem: i found a java script across internet for div pop up using overlay, working fine with all browsers except chrome. In chrome it would execute to create a popup but its position was top left of the screen and was viewable less than 50%.

Solutions: here is the solution.

if (!window.ie6) {
this.overlay.setStyles({
position: ‘fixed’,
top: 0,
left: 0
});
this.window.setStyles({
position: ‘fixed’,
top: ‘50%’,
left: ‘50%’
});
} else if (navigator.userAgent.indexOf(‘Chrome’) !=1) {

this.overlay.setStyles({
position: ‘absolute’,
top: ‘0%’,
left: ‘0%’
//,marginTop: “expression(document.documentElement.scrollTop + ‘px’)”
});

this.window.setStyles({
position: ‘absolute’,
top: ‘50%’,
left: ‘50%’
//,marginTop: “(expression(0 – parseInt(this.offsetHeight / 2) + document.documentElement.scrollTop + ‘px’)”
});

}else {
this.overlay.style.setExpression(‘marginTop’, ‘document.documentElement.scrollTop + “px”‘);
this.window.style.setExpression(‘marginTop’, ‘0 – parseInt(this.offsetHeight / 2) + document.documentElement.scrollTop + “px”‘);

this.overlay.setStyles({
position: ‘absolute’,
top: ‘0%’,
left: ‘0%’
//,marginTop: “expression(document.documentElement.scrollTop + ‘px’)”
});

this.window.setStyles({
position: ‘absolute’,
top: ‘0%’,
left: ‘0%’
//,marginTop: “(expression(0 – parseInt(this.offsetHeight / 2) + document.documentElement.scrollTop + ‘px’)”
});
}

javascript pop-up window close event

Add the below javascript to the javascript pop-up window on the close event of which you want to execute a particular javascript funciton.

window.onbeforeunload = 
 function(){
      // add the javascript code here which you want to execute at the close of this pop-up window
 }

modalbox javascript onclose event

Today after along period writing a post. I tried a new javascript library called modalbox js. Was working very good, but i had to run other javascript when the box was closed. Found some help at http://code.google.com/p/modalbox/wiki/MethodsReference but didn’t found the exact syntax.

After some trial and error finally succeeded, so thought to post on to the blog. Here is the syntax for javascript as well as for symfony (in case you are working with symfony)

Syntax for symfony:

<?php echo m_link_to(‘link_name’,
‘url’,
array(‘title’ => ‘title’),
array(‘width’ => 630, ‘height’ => 180, ‘afterHide’ => ‘afterhidealert‘)); ?>

here afterhidealert is the javascript function that will be called on the closing of the modalbox popup.

Syntax for javascript:

<a href=”url” onclick=”Modalbox.show(this.href, {afterHide:afterhidealert, height:180, title:this.title, width:630}); return false;” title=”title”>link_name</a>

here afterhidealert is the javascript function that will be called on the closing of the modalbox popup.

Thanks,

samsami2u

http://www.avidindiainc.com

ie 6 png fix – ie 6 png issue solutlion with css and/or js

The issue is with png type of images that are not properly displayed in ie 6 (internet explorer – Version 6). I found the solution somewhere on internet while googling.

Okay, so the solution goes as below:

1) download the files needed for the solution from http://demo.avidindiainc.com/ie6pngfix/ie6PNGFixDownload.zip

2) There are 5 files in the directory after you unzip it. They are  blank.gif, iepngfix.htc, iepngfix_tilebg.js, iepngfix.php and .htaccess.

3) for solving the issue the two files blank.gif and iepngfix.htc are enough. i will explain them first and we’ll go for the rest files later.

4) Copy and paste iepngfix.htc and blank.gif into your website folder.

5) Copy and paste this into your website’s CSS or HTML:

<style type=”text/css”>
img, div { behavior: url(iepngfix.htc) }
</style>

6) now the other  files work as follow. If you want support for CSS1 background-repeat and background-position, make sure you include the add-on .JS file in your <head>:

<script type=”text/javascript” src=”iepngfix_tilebg.js”></script>

7) Suppose if it works offline but not online, in this case you may have a MIME type problem. You must ensure your server is sending the correct MIME type of “text/x-component” for .HTC files. Try one of these two easy fixes:

  • Upload the “.htaccess” file from within this script’s download ZIP to your webserver, which will make Apache send the correct MIME type.
  • Instead of calling “IEPNGFIX.HTC” from your CSS, upload IEPNGFIX.PHP to the same folder and call that instead, which also sends the right MIME type.

Thats all folks. I hope this solves your issue with ie6.

flowplayer with auto playlist and seperate caption file for each clip along with external control bar

Flowplayer is free to download and available at flowplayer.org

it also have all these examples i.e.

1) Auto Playlist, 2)Playlist with captions on clips and 3)HTML Control bar

but here i have integrated all of the above three in one file/ one player

you can find the demo at http://demo.avidindiainc.com/flowplayer/

and you can download the files at http://demo.avidindiainc.com/flowplayer/flowplayer-download.zip

Thanks,

samsami2u

http://www.avidindiainc.com

ajax in internet explorer (ie) hangs up or Microsoft.XMLHTTP not working in ie

here is the possible solution:

function getHTTPObject() {

var httpObject = null;
// I think the issue has something to do with this area of code… (1)

if (window.ActiveXObject) { // IE
try {
httpObject = new ActiveXObject(“Microsoft.XMLHTTP”);
} catch (e) {
try {
httpObject = new ActiveXObject(“Msxml2.XMLHTTP”);
} catch (e) {}
}
}
else if (window.XMLHttpRequest) { // Mozilla, Safari,…
httpObject = new XMLHttpRequest();
if (httpObject.overrideMimeType) {
httpObject.overrideMimeType(‘text/html’);
}
}
if (httpObject == null) {
alert(‘Cannot create XMLHTTP instance’);
}
return httpObject;

}

now add the below given code:

var reqNum = rand(1,1000);
url_add = url_add + “&reqnum=” + reqNum;

httpObject.open(“GET”, “levels_dropdown.php?performance_id=” + url_add, true);

httpObject.send(null);

for the rand() function:

function rand (min, max) {

var argc = arguments.length;
if (argc === 0) {
min = 0;
max = 2147483647;
} else if (argc === 1) {
throw new Error(‘Warning: rand() expects exactly 2 parameters, 1 given’);
}
return Math.floor(Math.random() * (max – min + 1)) + min;

function rand (min, max) {
// http://kevin.vanzonneveld.net
// +   original by: Leslie Hoare
// +   bugfixed by: Onno Marsman
// %          note 1: See the commented out code below for a version which will work with our experimental (though probably unnecessary) srand() function)
// *     example 1: rand(1, 1);
// *     returns 1: 1

var argc = arguments.length;
if (argc === 0) {
min = 0;
max = 2147483647;
} else if (argc === 1) {
throw new Error(‘Warning: rand() expects exactly 2 parameters, 1 given’);
}
return Math.floor(Math.random() * (max – min + 1)) + min;

/*
// See note above for an explanation of the following alternative code

// +   reimplemented by: Brett Zamir (http://brett-zamir.me)
// –    depends on: srand
// %          note 1: This is a very possibly imperfect adaptation from the PHP source code
var rand_seed, ctx, PHP_RAND_MAX=2147483647; // 0x7fffffff

if (!this.php_js || this.php_js.rand_seed === undefined) {
this.srand();
}
rand_seed = this.php_js.rand_seed;

var argc = arguments.length;
if (argc === 1) {
throw new Error(‘Warning: rand() expects exactly 2 parameters, 1 given’);
}

var do_rand = function (ctx) {
return ((ctx * 1103515245 + 12345) % (PHP_RAND_MAX + 1));
};

var php_rand = function (ctxArg) { // php_rand_r
this.php_js.rand_seed = do_rand(ctxArg);
return parseInt(this.php_js.rand_seed, 10);
};

var number = php_rand(rand_seed);

if (argc === 2) {
number = min + parseInt(parseFloat(parseFloat(max) – min + 1.0) * (number/(PHP_RAND_MAX + 1.0)), 10);
}
return number;
*/
}

Ajax.InPlaceEditor

The in-place “text edit” testing allows for “on-the-fly” textfields. See the documentation on Ajax.InPlaceEditor and Ajax.InPlaceCollectionEditor

Syntax

new Ajax.InPlaceEditor( element, url, {options});

Options

Name since default Description
okControl V?? “button” What type of ok button to use in edit mode, or none at all (button, link, false)
cancelControl V?? “link” What type of cancel button to use in edit mode, or none at all (button, link, false)
okText V1.5 “ok” The text of the submit button that submits the changed value to the server
cancelText V1.5 “cancel” The text of the link that cancels editing
savingText V1.5 “Saving…” The text shown while the text is sent to the server
clickToEditText V1.6 “Click to edit” The text shown during mouseover the editable text
formId V1.5 id of the element to edit plus ‘InPlaceForm’ The id given to the element
externalControl V1.5 null ID of an element that acts as an external control used to enter edit mode. The external control will be hidden when entering edit mode and shown again when leaving edit mode.
externalControlOnly V1.5 false Whether or not to disable onclick editing so that only an external control can activate editable mode
rows V1.5 1 The row height of the input field (anything greater than 1 uses a multiline textarea for input)
onComplete V1.6 “function(transport, element) {new Effect.Highlight(element, {startcolor: this.options.highlightcolor});}” Code run if update successful with server
onFailure V1.6 “function(transport) {alert(“Error communicating with the server: ” + transport.responseText.stripTags());}” Code run if update failed with server
cols V1.5 none The number of columns the text area should span (works for both single line or multi line)
size V1.5 none Synonym for ‘cols’ when using single-line (rows=1) input
highlightcolor ? Ajax.InPlaceEditor.defaultHighlightColor The highlight color
highlightendcolor ? ”#FFFFFF” The color which the highlight fades to
savingClassName V1.5 “inplaceeditor-saving” CSS class added to the element while displaying “Saving…” (removed when server responds)
formClassName V1.5 “inplaceeditor-form” CSS class used for the in place edit form
hoverClassName ? ? ?
loadTextURL V1.5 null Will cause the text to be loaded from the server (useful if your text is actually textile and formatted on the server)
loadingText V1.5 “Loading…” If the loadText URL option is specified then this text is displayed while the text is being loaded from the server
callback V1.5 function(form) {Form.serialize(form)} A function that will get executed just before the request is sent to the server, should return the parameters to be sent in the URL. Will get two parameters, the entire form and the value of the text control.
submitOnBlur V1.6 “false” This option if true will submit the in_place_edit form when the input tag loses focus.
ajaxOptions V1.5 {} Options specified to all AJAX calls (loading and saving text), these options are passed through to the prototype AJAX classes.

The server side component gets the new value as the parameter ‘value’ (POST method), and should send the new value as the body of the response.


for more information please check this url: http://wiki.github.com/madrobby/scriptaculous/ajax-inplaceeditor

prototype.js / jQuery.js conflict and resolution

when you use jQuery and prototype javascript frameworks togather on the same page, it creates conflicts.

jQuery has provided a resolution to this conflict. The resolution goes as below:

Overriding the $-function:

1) you can override that default by calling jQuery.noConflict() at any point after jQuery and the other library have both loaded. For example:

 <html>
 <head>
   <script src="prototype.js"></script>
   <script src="jquery.js"></script>
   <script>
     jQuery.noConflict();

     // Use jQuery via jQuery(...)
     jQuery(document).ready(function(){
       jQuery("div").hide();
     });

     // Use Prototype with $(...), etc.
     $('someid').hide();
   </script>
 </head>
 <body></body>

 </html>

2) Additionally, there's another option. If you want to make sure that
jQuery won't conflict with another library - but you want the benefit
of a short name, you could do something like this:

 <html>
 <head>
   <script src="prototype.js"></script>
   <script src="jquery.js"></script>
   <script>
     var $j = jQuery.noConflict();

     // Use jQuery via $j(...)
     $j(document).ready(function(){
       $j("div").hide();
     });

     // Use Prototype with $(...), etc.
     $('someid').hide();
   </script>
 </head>
 <body></body>
 </html>

For more information on the above topic please refer to http://docs.jquery.com/Using_jQuery_with_Other_Libraries