/    Sign up×
Community /Pin to ProfileBookmark

Conflict with javascript codes

Hello everyone. I have no experience with javascript, and am trying to setup a site for a friend that includes a flash video as well as a tabbed menu. But there is some conflict with the codes. I don’t know where to begin. Can anyone provide any assistance? Here are the 3 separate jscript codes.

Flash Video initial

[CODE]
function MM_CheckFlashVersion(reqVerStr,msg){
with(navigator){
var isIE = (appVersion.indexOf(“MSIE”) != -1 && userAgent.indexOf(“Opera”) == -1);
var isWin = (appVersion.toLowerCase().indexOf(“win”) != -1);
if (!isIE || !isWin){
var flashVer = -1;
if (plugins && plugins.length > 0){
var desc = plugins[“Shockwave Flash”] ? plugins[“Shockwave Flash”].description : “”;
desc = plugins[“Shockwave Flash 2.0”] ? plugins[“Shockwave Flash 2.0”].description : desc;
if (desc == “”) flashVer = -1;
else{
var descArr = desc.split(” “);
var tempArrMajor = descArr[2].split(“.”);
var verMajor = tempArrMajor[0];
var tempArrMinor = (descArr[3] != “”) ? descArr[3].split(“r”) : descArr[4].split(“r”);
var verMinor = (tempArrMinor[1] > 0) ? tempArrMinor[1] : 0;
flashVer = parseFloat(verMajor + “.” + verMinor);
}
}
// WebTV has Flash Player 4 or lower — too low for video
else if (userAgent.toLowerCase().indexOf(“webtv”) != -1) flashVer = 4.0;

var verArr = reqVerStr.split(“,”);
var reqVer = parseFloat(verArr[0] + “.” + verArr[2]);

if (flashVer < reqVer){
if (confirm(msg))
window.location = “http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash”;
}
}
}
}[/CODE]

Flash Video run active content

[CODE]
var isIE = (navigator.appVersion.indexOf(“MSIE”) != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf(“win”) != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf(“Opera”) != -1) ? true : false;

function ControlVersion()
{
var version;
var axo;
var e;

try {
axo = new ActiveXObject(“ShockwaveFlash.ShockwaveFlash.7”);
version = axo.GetVariable(“$version”);
} catch (e) {
}

if (!version)
{
try {
axo = new ActiveXObject(“ShockwaveFlash.ShockwaveFlash.6”);
version = “WIN 6,0,21,0”;
axo.AllowScriptAccess = “always”;
version = axo.GetVariable(“$version”);

} catch (e) {
}
}

if (!version)
{
try {
axo = new ActiveXObject(“ShockwaveFlash.ShockwaveFlash.3”);
version = axo.GetVariable(“$version”);
} catch (e) {
}
}

if (!version)
{
try {
axo = new ActiveXObject(“ShockwaveFlash.ShockwaveFlash.3”);
version = “WIN 3,0,18,0”;
} catch (e) {
}
}

if (!version)
{
try {
axo = new ActiveXObject(“ShockwaveFlash.ShockwaveFlash”);
version = “WIN 2,0,0,11”;
} catch (e) {
version = -1;
}
}

return version;
}

function GetSwfVer(){
var flashVer = -1;

if (navigator.plugins != null && navigator.plugins.length > 0) {
if (navigator.plugins[“Shockwave Flash 2.0”] || navigator.plugins[“Shockwave Flash”]) {
var swVer2 = navigator.plugins[“Shockwave Flash 2.0″] ? ” 2.0″ : “”;
var flashDescription = navigator.plugins[“Shockwave Flash” + swVer2].description;
var descArray = flashDescription.split(” “);
var tempArrayMajor = descArray[2].split(“.”);
var versionMajor = tempArrayMajor[0];
var versionMinor = tempArrayMajor[1];
var versionRevision = descArray[3];
if (versionRevision == “”) {
versionRevision = descArray[4];
}
if (versionRevision[0] == “d”) {
versionRevision = versionRevision.substring(1);
} else if (versionRevision[0] == “r”) {
versionRevision = versionRevision.substring(1);
if (versionRevision.indexOf(“d”) > 0) {
versionRevision = versionRevision.substring(0, versionRevision.indexOf(“d”));
}
}
var flashVer = versionMajor + “.” + versionMinor + “.” + versionRevision;
}
}
else if (navigator.userAgent.toLowerCase().indexOf(“webtv/2.6”) != -1) flashVer = 4;
else if (navigator.userAgent.toLowerCase().indexOf(“webtv/2.5”) != -1) flashVer = 3;
else if (navigator.userAgent.toLowerCase().indexOf(“webtv”) != -1) flashVer = 2;
else if ( isIE && isWin && !isOpera ) {
flashVer = ControlVersion();
}
return flashVer;
}

function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
versionStr = GetSwfVer();
if (versionStr == -1 ) {
return false;
} else if (versionStr != 0) {
if(isIE && isWin && !isOpera) {
// Given “WIN 2,0,0,11″
tempArray = versionStr.split(” “); // [“WIN”, “2,0,0,11”]
tempString = tempArray[1]; // “2,0,0,11”
versionArray = tempString.split(“,”); // [‘2’, ‘0’, ‘0’, ’11’]
} else {
versionArray = versionStr.split(“.”);
}
var versionMajor = versionArray[0];
var versionMinor = versionArray[1];
var versionRevision = versionArray[2];

if (versionMajor > parseFloat(reqMajorVer)) {
return true;
} else if (versionMajor == parseFloat(reqMajorVer)) {
if (versionMinor > parseFloat(reqMinorVer))
return true;
else if (versionMinor == parseFloat(reqMinorVer)) {
if (versionRevision >= parseFloat(reqRevision))
return true;
}
}
return false;
}
}

function AC_AddExtension(src, ext)
{
if (src.indexOf(‘?’) != -1)
return src.replace(/?/, ext+’?’);
else
return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs)
{
var str = ”;
if (isIE && isWin && !isOpera)
{
str += ‘<object ‘;
for (var i in objAttrs)
{
str += i + ‘=”‘ + objAttrs[i] + ‘” ‘;
}
str += ‘>’;
for (var i in params)
{
str += ‘<param name=”‘ + i + ‘” value=”‘ + params[i] + ‘” /> ‘;
}
str += ‘</object>’;
}
else
{
str += ‘<embed ‘;
for (var i in embedAttrs)
{
str += i + ‘=”‘ + embedAttrs[i] + ‘” ‘;
}
str += ‘> </embed>’;
}

document.write(str);
}

function AC_FL_RunContent(){
var ret =
AC_GetArgs
( arguments, “.swf”, “movie”, “clsid:d27cdb6e-ae6d-11cf-96b8-444553540000”
, “application/x-shockwave-flash”
);
AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
var ret =
AC_GetArgs
( arguments, “.dcr”, “src”, “clsid:166B1BCA-3F9C-11CF-8075-444553540000”
, null
);
AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
var ret = new Object();
ret.embedAttrs = new Object();
ret.params = new Object();
ret.objAttrs = new Object();
for (var i=0; i < args.length; i=i+2){
var currArg = args[i].toLowerCase();

switch (currArg){
case “classid”:
break;
case “pluginspage”:
ret.embedAttrs[args[i]] = args[i+1];
break;
case “src”:
case “movie”:
args[i+1] = AC_AddExtension(args[i+1], ext);
ret.embedAttrs[“src”] = args[i+1];
ret.params[srcParamName] = args[i+1];
break;
case “onafterupdate”:
case “onbeforeupdate”:
case “onblur”:
case “oncellchange”:
case “onclick”:
case “ondblClick”:
case “ondrag”:
case “ondragend”:
case “ondragenter”:
case “ondragleave”:
case “ondragover”:
case “ondrop”:
case “onfinish”:
case “onfocus”:
case “onhelp”:
case “onmousedown”:
case “onmouseup”:
case “onmouseover”:
case “onmousemove”:
case “onmouseout”:
case “onkeypress”:
case “onkeydown”:
case “onkeyup”:
case “onload”:
case “onlosecapture”:
case “onpropertychange”:
case “onreadystatechange”:
case “onrowsdelete”:
case “onrowenter”:
case “onrowexit”:
case “onrowsinserted”:
case “onstart”:
case “onscroll”:
case “onbeforeeditfocus”:
case “onactivate”:
case “onbeforedeactivate”:
case “ondeactivate”:
case “type”:
case “codebase”:
case “id”:
ret.objAttrs[args[i]] = args[i+1];
break;
case “width”:
case “height”:
case “align”:
case “vspace”:
case “hspace”:
case “class”:
case “title”:
case “accesskey”:
case “name”:
case “tabindex”:
ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
break;
default:
ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
}
}
ret.objAttrs[“classid”] = classid;
if (mimeType) ret.embedAttrs[“type”] = mimeType;
return ret;
}
[/CODE]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@optimus203authorJan 04.2009 — Here is the other jscript code for the Tabbed menu
[CODE]
function tabberObj(argsObj)
{
var arg;

this.div = null;
this.classMain = "tabber";
this.classMainLive = "tabberlive";
this.classTab = "tabbertab";
this.classTabDefault = "tabbertabdefault";
this.classNav = "tabbernav";
this.classTabHide = "tabbertabhide";
this.classNavActive = "tabberactive";
this.titleElements = ['h2','h3','h4','h5','h6'];
this.titleElementsStripHTML = true;
this.removeTitle = true;
this.addLinkId = false;
this.linkIdFormat = '<tabberid>nav<tabnumberone>';

for (arg in argsObj) { this[arg] = argsObj[arg]; }

this.REclassMain = new RegExp('\b' + this.classMain + '\b', 'gi');
this.REclassMainLive = new RegExp('\b' + this.classMainLive + '\b', 'gi');
this.REclassTab = new RegExp('\b' + this.classTab + '\b', 'gi');
this.REclassTabDefault = new RegExp('\b' + this.classTabDefault + '\b', 'gi');
this.REclassTabHide = new RegExp('\b' + this.classTabHide + '\b', 'gi');

this.tabs = new Array();

if (this.div) {

this.init(this.div);
this.div = null;
}
}

tabberObj.prototype.init = function(e)
{
var
childNodes, /* child nodes of the tabber div */
i, i2, /* loop indices */
t, /* object to store info about a single tab */
defaultTab=0, /* which tab to select by default */
DOM_ul, /* tabbernav list */
DOM_li, /* tabbernav list item */
DOM_a, /* tabbernav link */
aId, /* A unique id for DOM_a */
headingElement; /* searching for text to use in the tab */

if (!document.getElementsByTagName) { return false; }

if (e.id) {
this.id = e.id;
}

this.tabs.length = 0;

childNodes = e.childNodes;
for(i=0; i < childNodes.length; i++) {

if(childNodes[i].className &&
childNodes[i].className.match(this.REclassTab)) {

t = new Object();

t.div = childNodes[i];

this.tabs[this.tabs.length] = t;

if (childNodes[i].className.match(this.REclassTabDefault)) {
defaultTab = this.tabs.length-1;
}
}
}

DOM_ul = document.createElement("ul");
DOM_ul.className = this.classNav;

for (i=0; i < this.tabs.length; i++) {

t = this.tabs[i];
t.headingText = t.div.title;

if (this.removeTitle) { t.div.title = ''; }
if (!t.headingText) {

for (i2=0; i2<this.titleElements.length; i2++) {
headingElement = t.div.getElementsByTagName(this.titleElements[i2])[0];
if (headingElement) {
t.headingText = headingElement.innerHTML;
if (this.titleElementsStripHTML) {
t.headingText.replace(/<br>/gi," ");
t.headingText = t.headingText.replace(/<[^>]+>/g,"");
}
break;
}
}
}

if (!t.headingText) {
t.headingText = i + 1;
}

DOM_li = document.createElement("li");

t.li = DOM_li;

DOM_a = document.createElement("a");
DOM_a.appendChild(document.createTextNode(t.headingText));
DOM_a.href = "javascript:void(null);";
DOM_a.title = t.headingText;
DOM_a.onclick = this.navClick;
DOM_a.tabber = this;
DOM_a.tabberIndex = i;

if (this.addLinkId && this.linkIdFormat) {

aId = this.linkIdFormat;
aId = aId.replace(/<tabberid>/gi, this.id);
aId = aId.replace(/<tabnumberzero>/gi, i);
aId = aId.replace(/<tabnumberone>/gi, i+1);
aId = aId.replace(/<tabtitle>/gi, t.headingText.replace(/[^a-zA-Z0-9-]/gi, ''));

DOM_a.id = aId;
}

DOM_li.appendChild(DOM_a);

DOM_ul.appendChild(DOM_li);
}

e.insertBefore(DOM_ul, e.firstChild);

e.className = e.className.replace(this.REclassMain, this.classMainLive);

this.tabShow(defaultTab);

if (typeof this.onLoad == 'function') {
this.onLoad({tabber:this});
}

return this;
};


tabberObj.prototype.navClick = function(event)
{
var
rVal,
a,
self,
tabberIndex,
onClickArgs;

a = this;
if (!a.tabber) { return false; }

self = a.tabber;
tabberIndex = a.tabberIndex;

a.blur();

if (typeof self.onClick == 'function') {

onClickArgs = {'tabber':self, 'index':tabberIndex, 'event':event};

if (!event) { onClickArgs.event = window.event; }

rVal = self.onClick(onClickArgs);
if (rVal === false) { return false; }
}

self.tabShow(tabberIndex);

return false;
};


tabberObj.prototype.tabHideAll = function()
{
var i; /* counter */

for (i = 0; i < this.tabs.length; i++) {
this.tabHide(i);
}
};


tabberObj.prototype.tabHide = function(tabberIndex)
{
var div;

if (!this.tabs[tabberIndex]) { return false; }

div = this.tabs[tabberIndex].div;

if (!div.className.match(this.REclassTabHide)) {
div.className += ' ' + this.classTabHide;
}
this.navClearActive(tabberIndex);

return this;
};


tabberObj.prototype.tabShow = function(tabberIndex)
{
var div;

if (!this.tabs[tabberIndex]) { return false; }

this.tabHideAll();

div = this.tabs[tabberIndex].div;
div.className = div.className.replace(this.REclassTabHide, '');
this.navSetActive(tabberIndex);
if (typeof this.onTabDisplay == 'function') {
this.onTabDisplay({'tabber':this, 'index':tabberIndex});
}

return this;
};

tabberObj.prototype.navSetActive = function(tabberIndex)
{
this.tabs[tabberIndex].li.className = this.classNavActive;
return this;
};


tabberObj.prototype.navClearActive = function(tabberIndex)
{
this.tabs[tabberIndex].li.className = '';
return this;
};

function tabberAutomatic(tabberArgs)
{
var
tempObj,
divs,
i;

if (!tabberArgs) { tabberArgs = {}; }

tempObj = new tabberObj(tabberArgs);

divs = document.getElementsByTagName("div");
for (i=0; i < divs.length; i++) {

if (divs[i].className &&
divs[i].className.match(tempObj.REclassMain)) {

tabberArgs.div = divs[i];
divs[i].tabber = new tabberObj(tabberArgs);
}
}

return this;
}

function tabberAutomaticOnLoad(tabberArgs)
{
var oldOnLoad;

if (!tabberArgs) { tabberArgs = {}; }

oldOnLoad = window.onload;
if (typeof window.onload != 'function') {
window.onload = function() {
tabberAutomatic(tabberArgs);
};
} else {
window.onload = function() {
oldOnLoad();
tabberAutomatic(tabberArgs);
};
}
}

if (typeof tabberOptions == 'undefined') {

tabberAutomaticOnLoad();

} else {

if (!tabberOptions['manualStartup']) {
tabberAutomaticOnLoad(tabberOptions);
}

}
[/CODE]
Copy linkTweet thisAlerts:
@optimus203authorJan 04.2009 — I noticed that I had duplicate window.onLoad functions going on, so I jsut deleted the Flash version verification.

I do notice that when a page containing the tabbed menu opens, the menu appears for a second unformatted while the page is loading. It looks quite unattractive. Is there a solution to bypass this? ie, hiding the menu until the page fully loads?
×

Success!

Help @optimus203 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.8,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...