FF3/Windows CSS z-index problem with YouTube player - css

I'm stuck on what appears to be a CSS/z-index conflict with the YouTube player. In Firefox 3 under Windows XP, Take a look at this page: http://spokenword.org/program/21396 Click on the Collect button and note that the pop-up <div> appears under the YouTube player. On other browsers the <div> appears on top. It has a z-index value of 999999. I've tried setting the z-index of the <object> element containing the player to a lower value, but that didn't work. Any idea how to get the pop-up to appear over the player?

Try to add the wmode parameter to be opaque like this:
(Note that it's included in both a <param> tag and a wmode attribute on the <embed> tag.)
<object width='425' height='344'>
<param name='movie' value='http://www.youtube.com/v/Wj_JNwNbETA&hl=en&fs=1'>
<param name='type' value='application/x-shockwave-flash'>
<param name='allowfullscreen' value='true'>
<param name='allowscriptaccess' value='always'>
<param name="wmode" value="opaque" />
<embed width='425' height='344'
src='http://www.youtube.com/v/Wj_JNwNbETA&hl=en&fs=1'
type='application/x-shockwave-flash'
allowfullscreen='true'
allowscriptaccess='always'
wmode="opaque"
></embed>
</object>

although the recommendation by CMS is valid, there is an important update. If you want to use 'iframe' instead of 'embed' , simply add ?wmode=transparent to your video link and that does the magic. I find this more simple and clean.
Update, Feb 2014
It's been a while and this may be outdated.
Somebody reported that now &wmode=transparent works instead.

i've found a pure JS function that fix it in all browsers!
there you go:
function fix_flash() {
// loop through every embed tag on the site
var embeds = document.getElementsByTagName('embed');
for (i = 0; i < embeds.length; i++) {
embed = embeds[i];
var new_embed;
// everything but Firefox & Konqueror
if (embed.outerHTML) {
var html = embed.outerHTML;
// replace an existing wmode parameter
if (html.match(/wmode\s*=\s*('|")[a-zA-Z]+('|")/i))
new_embed = html.replace(/wmode\s*=\s*('|")window('|")/i, "wmode='transparent'");
// add a new wmode parameter
else
new_embed = html.replace(/<embed\s/i, "<embed wmode='transparent' ");
// replace the old embed object with the fixed version
embed.insertAdjacentHTML('beforeBegin', new_embed);
embed.parentNode.removeChild(embed);
} else {
// cloneNode is buggy in some versions of Safari & Opera, but works fine in FF
new_embed = embed.cloneNode(true);
if (!new_embed.getAttribute('wmode') || new_embed.getAttribute('wmode').toLowerCase() == 'window')
new_embed.setAttribute('wmode', 'transparent');
embed.parentNode.replaceChild(new_embed, embed);
}
}
// loop through every object tag on the site
var objects = document.getElementsByTagName('object');
for (i = 0; i < objects.length; i++) {
object = objects[i];
var new_object;
// object is an IE specific tag so we can use outerHTML here
if (object.outerHTML) {
var html = object.outerHTML;
// replace an existing wmode parameter
if (html.match(/<param\s+name\s*=\s*('|")wmode('|")\s+value\s*=\s*('|")[a-zA-Z]+('|")\s*\/?\>/i))
new_object = html.replace(/<param\s+name\s*=\s*('|")wmode('|")\s+value\s*=\s*('|")window('|")\s*\/?\>/i, "<param name='wmode' value='transparent' />");
// add a new wmode parameter
else
new_object = html.replace(/<\/object\>/i, "<param name='wmode' value='transparent' />\n</object>");
// loop through each of the param tags
var children = object.childNodes;
for (j = 0; j < children.length; j++) {
try {
if (children[j] != null) {
var theName = children[j].getAttribute('name');
if (theName != null && theName.match(/flashvars/i)) {
new_object = new_object.replace(/<param\s+name\s*=\s*('|")flashvars('|")\s+value\s*=\s*('|")[^'"]*('|")\s*\/?\>/i, "<param name='flashvars' value='" + children[j].getAttribute('value') + "' />");
}
}
}
catch (err) {
}
}
// replace the old embed object with the fixed versiony
object.insertAdjacentHTML('beforeBegin', new_object);
object.parentNode.removeChild(object);
}
}
}
now you can just run in when the page loads with jQuery:
$(document).ready(function () {
fix_flash();
});

We use jQuery Flash plugin to convert YouTube links to Flash movies. In this case, wmode is passed as an option in order to get the YouTube video to appear underneath the jQuery Dialog we open:
$('a[href^="http://www.youtube.com"]').flash(
{ width: nnn, height: nnn, wmode: 'opaque' }
);

I've noticed that wmode="opaque" terribly affects on usage of CPU.
Chrome make on my notebook 50% CPU usage (without opaque ~8%).
So be careful with this option.

Related

Flex Fullscreen Problems

I'm having problems with Full Screen in Flex.
Here's the Code:
private function toggleFullScreen(event:Event):void {
try {
switch (Application.application.stage.displayState) {
case StageDisplayState.FULL_SCREEN:
// If already in full screen mode, switch to normal mode.
Application.application.stage.displayState = StageDisplayState.NORMAL;
break;
default:
//If not in full screen mode, switch to full screen mode.
Application.application.stage.displayState = StageDisplayState.FULL_SCREEN;
break;
}
} catch (err:SecurityError) {
// ignore
}
}
I've already verified that this method is correctly being called, and that the SWITCH/CASE is working.
Still, after setting the displayState, nothing happens, and the attribute displayState remais with "normal" String.
I tested with previous versions of Firefox and Internet Explorer, but it didn't work either.
Does anybody know why is this happening? I'm new in flex and this code was developed by previous developers, that aren't working here anymore.
I've been searching a fix for weeks, but I didn't find anything that could help.
Thanks for the help.
Most likely you need to include the "allowFullscreen" in both of your param tag and embed attribute within the HTML template:
<object>
...
<param name="allowFullScreen" value="true" />
<embed ... allowfullscreen="true" />
</object>
And just a reference to the stage should be enough:
stage.displayState = StageDisplayState.FULL_SCREEN;

In Chrome ajax async postback end does not work

I have a sample app developed in asp.NET 3.5. On my master page I use following code to display an GIF while loading the page. It works correctly on IE and FF, but fails in Chrome. On pressing the submit button, the server gets the request and completes its processing and while that is happening the browser shows the loading GIF as expected.However the postback never completes and user keeps on looking at the progress GIF. I wonder where I have goofed up... Pls help!
// Get the instance of PageRequestManager.
var prm = Sys.WebForms.PageRequestManager.getInstance();
// Add initializeRequest and endRequest
prm.add_initializeRequest(prm_InitializeRequest);
prm.add_endRequest(prm_EndRequest);
// Called when async postback begins
function prm_InitializeRequest(sender, args) {
// get the divImage and set it to visible
var panelProg = $get('divImage');
if( panelProg != null)
{
panelProg.style.display = '';
// Disable button that caused a postback
$get(args._postBackElement.id).disabled = true;
}
}
// Called when async postback ends
function prm_EndRequest(sender, args) {
// get the divImage and hide it again
var panelProg = $get('divImage');
if(panelProg != null)
{
panelProg.style.display = 'none';
$get(sender._postBackSettings.sourceElement.id).disabled = false;
}
}
My divImage is simple
<div id="divImage" style="display: none">
<img id="imgId1" src="../../App_Themes/Images/progressbar.gif" style="border-width:0px;" />
<br />
Please wait...
</div>
Add the following script to your page.
<script type="text/javascript">
Sys.Browser.WebKit = {}; //Safari 3 is considered WebKit
if( navigator.userAgent.indexOf( 'WebKit/' ) > -1 )
{
Sys.Browser.agent = Sys.Browser.WebKit;
Sys.Browser.version = parseFloat( navigator.userAgent.match(/WebKit\/(\d+(\.\d+)?)/)[1]);
Sys.Browser.name = 'WebKit';
}
</script>
See more at: http://blog.joeydaly.com/uncaught-sys-scriptloadfailedexception-sys-scriptloadfailedexception
I have problems with ajax in Chrome in my dev environment(localhost without a .something domain). When I switch to acceptance Chrome works fine. In what environment are you working?
What you could try is change the dev url in your host file to something with an extention.

ASP.MVC Ajax response returns form with some JS not executing

ASP.NET MVC Page has one link (Ajax.ActionLink), which gets the form to create and puts it in one of the div. I see the form in div but none of the JavaScript returned is getting executed. I am using JQuery validation and needs to run the validate() on the form so that returned form from AJAX request is validated.
Is there any setting or trick I am missing?
Thanks
If you're using jQuery, just replace the Sys.Mvc.MvcHelpers.updateDomElement with your own implementation.
(function ($) {
if (Sys && Sys.Mvc && Sys.Mvc.MvcHelpers) {
Sys.Mvc.MvcHelpers.updateDomElement = function My$updateDomElement(target, insertionMode, content) {
/// <param name="target" type="Object" domElement="true">
/// </param>
/// <param name="insertionMode" type="Sys.Mvc.InsertionMode">
/// </param>
/// <param name="content" type="String">
/// </param>
if (target) {
var $target = $(target);
switch (insertionMode) {
case Sys.Mvc.InsertionMode.replace:
$target.html(content);
break;
case Sys.Mvc.InsertionMode.insertBefore:
if (content && content.length > 0) {
$target.prepend(content);
}
break;
case Sys.Mvc.InsertionMode.insertAfter:
if (content && content.length > 0) {
$target.append(content);
}
break;
}
}
}
}
})(jQuery);
Since jQuery handles script tags correctly, that should fix your problem.
There is 2 ways I have it working now.
User the JQuery $.get and replace the html returned into the div. This is now executing the script for me.
Other option is remove the UpdateTargetId and ReplaceMode from the AjaxOptions and use call back to replace the html into div tag.

how to enable an css property for the ajax tab panel using javascript

i am using asp.net ajax tab container[ which has 2 tab panel]
under each tab panel i have an div tag. now by default.i have my Activetabindex="0"
now i need to enable css property for the div tag using javscript so that there is no post back happening. i doing like this css property for the tab panel 1 is not getting applied
this is my script what i doing. if i do the same thing in code behind for the ta selected index change it works. but thatcause an post back.
now i need t o do it my javscript only
OnClientActiveTabChanged="PanelClick"
<script type="text/javascript" language="javascript">
function PanelClick(Sender, e) {
debugger;
var CurrentTab = $find('<%=Tab1.ClientID%>');
if( Sender._activeTabIndex==0) {
debugger
document.getElementById('<%=mycustomscroll2.ClientID%>').className = '';
document.getElementById('<%=mycustomscroll2.ClientID%>').Enabled = false;
document.getElementById('<%=mycustomscroll.ClientID%>').className = 'flexcroll';
}
if (Sender._activeTabIndex == 1) {
debugger
document.getElementById('<%=mycustomscroll.ClientID%>').className = '';
document.getElementById('<%=mycustomscroll.ClientID%>').Enabled= false ;
document.getElementById('<%=mycustomscroll2.ClientID%>').className = 'flexcroll';
}
}
</script>
so how to i enable my css property for the div using javascript for the tab panel
anyhelp would be great
thank you
Here is a javascript function which will sort of do what you want:
function PanelClick(Sender, e) {
var scroll1 = $get('<%=mycustomscroll.ClientID%>');
var scroll2 = $get('<%=mycustomscroll2.ClientID%>');
if(Sender._activeTabIndex == 0) {
scroll1.setAttribute('class', 'flexcroll');
scroll2.setAttribute('class', '');
} else if(Sender._activeTabIndex == 1) {
scroll1.setAttribute('class', '');
scroll2.setAttribute('class', 'flexcroll');
}
}
There really is no such thing as "enabled" in HTML and JavaScript. HTML has a "disabled" attribute, but it only applies to these elements: button, input, optgroup, option, select and textarea. It is used like so:
<input type="text" name="txtSomething" id="txtSomething" disabled="disabled">
and in JavaScript, similar to setting the class attribute, above:
$get('txtSomething').setAttribute('disabled','disabled'); // disable the input
$get('txtSomething').setAttribute('disabled',''); // enable the input
But this will not work for other elements like <div> and <span> tags.

Will this jscript run inside a .ASCX page?

Will this run inside an ASCX file in my ASP.Net project?
I can't seem to get it to work, just wondered if there was some particular thing missing? Do i need to include "runat="server""?
<!--[if lte IE 6]>
<script type="text/javascript">
window.onload = function() {
var images = document.getElementById("GetQuote").getAttribute("ImageUrl");
for (var i = 0; i < images.length; i++) {
var image_png_src = images[i].src;
var image_gif_src = image_png_src.replace(".png", ".gif");
images[i].src = image_gif_src;
}
};
</script>
<![endif]-->
It appears that this JavaScript function is attempting to reference ASP.NET web control properties, which are not accessible from the client side. You can, however, reference the HTML entities that are output to the page by ASP.NET, along with their attributes.
Assuming your JavaScript code is code within the .ascx code, change this line:
var images = document.getElementById("GetQuote").getAttribute("ImageUrl");
To this:
var images = document.getElementById('<%=GetQuote.ClientID%>').getAttribute("src");
What this does is insert the client ID that ASP.NET creates for the GetQuote Image control so that it can be referenced from the client side. It also references the proper attribute of the HTML img element (src) that corresponds to the ImageUrl property of the server side Image control.
EDIT:
I noticed after seeing TheVillageIdiot's response (and reading your code a bit more closely, which I should have done initially) that you are trying to use the images variable as an array. It appears that you may be trying to match several image elements that contain the text "GetQuote" in their IDs (like GetQuote1, GetQuote2, etc.).
Assuming that you need to do this on the client side, and that you are not using a framework like jQuery, try this:
window.onload = function()
{
// get all img elements on the page and load them into an array
var images = document.getElementsByTagName("img");
// iterate through the image array
for (var i = 0; i < images.length; i++)
{
// check that the current image's id contains "GetQuote" (case sensitive)
if (images[i].id.indexOf("GetQuote") >= 0)
{
var image_png_src = images[i].src;
var image_gif_src = image_png_src.replace(".png", ".gif");
images[i].src = image_gif_src;
}
}
};
You don't need a runat="server" because this is code that will run on the client. It should work, but maybe you are having problems because you are referencing IDs on items that are asp.net controls? This would mean that your ID values would not match. If so you could solve this by using control.ClientID redndered into the JavaScript server-side to make them match.
If GetQuote is an aspx element then you need to replace it with <%= GetQuote.ClientID %> and ImageUrl with src like
var images = document.getElementById('<%=GetQuote.ClientID%>')
.getAttribute("src");
Also images should be one string not an array of strings so your loop is also at fault. Try this one instead:
var image = document.getElementById('<%=GetQuote.ClientID%>').
if(images){
var src = image.GetAttribute("src");
image.SetAttribute("src",src.replace(".png", ".gif");
}

Resources