Draggable is not working getting the uncaught reference error - javascript

I am trying to add a draggable to the frames but it is not working and throwing the below exception
created the Frames using iframe but could not apply the draggable for my frames.Please help me to solve my problem.
Uncaught ReferenceError: HSplitter is not defined at HTMLDivElement.onmousedown
Please find my code below:
var HSplitter = {
mouseDown: function (_split, event)
{
if(!this.isToggle)
{
this.parent = _split.parentNode.parentNode; //td
this.currentSplit = _split;
this.splitterWidth = $(this.currentSplit).getWidth();
this.splitPointX = Event.pointerX(event);
this.drag = true;
this.splitDiv = $(this.parent).getElementsByClassName("HSplitDiv")[0];
//min width of a parent container couldn't be less than splitter width.
if( this.minWidth < this.splitterWidth )
this.minWidth = this.splitterWidth;
this.mouseOver(_split, event);
$(this.splitDiv).setStyle({paddingRight: '0px'}); //reset padding
this._splitDivOverflow(true); //set overflow to ON
}
},
mouseUp: function (split, event)
{
if(!this.isToggle)
{
this.drag = false;
this._setDynamicOverflow();
}
},
};
<head>
<link href="/Work/css/tab_style.css" type="text/css" rel="stylesheet"/>
<link href="D:/cnsdi-projects/style.css" type="text/css" rel="stylesheet"/>
<link rel="stylesheet" href="/Work/css/1.10.19/dataTables.bootstrap.min.css">
<link rel="stylesheet" href="/Work/css/1.10.19/bootstrap.min.css">
<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.min.js" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js">
</script>
<script type="text/javascript" src="/Work/js/3.3.7/bootstrap.min.js">
</script>
</head>
<body>
<div class="tab-content" >
<div id="sectionA" class="tab-pane fade in active" style="overflow:visible;">
<iframe scrolling="yes" src="pg1.html" name="leftside" style="position:absolute;top:140px;left:0%;width:25%;height:100%;border: none;" ></iframe>
<div class="split1" onselect="return false;" unselectable="on" onmouseup="HSplitter.mouseUp(this, event);" onmousedown="HSplitter.setMaxMinWidth('-1','-1'); HSplitter.mouseDown(this, event);" style="left: auto;">
<span class="collapse l-splt-btn" onclick="HSplitter.splitToggle(this);"></span>
</div>
<iframe src="pg2.html" name="rightside" scrolling="yes" style="position:absolute;top:140px;left:25%;width:75%;height:50%;border: none;"></iframe>
<div class="split"><div class="vcollapse d-splt-btn" onclick="VSplitter.splitToggle(this);" toppaneheight="50%" id="idx1320192_vspltbtn"></div></div>
<iframe src="pg3.html" name="rightside" scrolling="yes" style="position:absolute;top:450px;left:25%;width:75%;height:30%;border: none;"></iframe>
</div>
</body>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/gsap/latest/TweenMax.min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/gsap/latest/utils/Draggable.min.js"></script>
Please input this code in your site header and if it doesn't work , let me know.
Thank you!

Related

How to limit user from opening Bootstrap Tab-Panes with maximum 5?

The user needs to be limited to open only 5 tab-panes (Max) although multiple tab buttons are available. After 6th tab is clicked, user needs to be alerted.
function addTab(title, url){
var tabs=$(".tabs"),
tabsContent=tabs.children("a");
if(tabsContent.find(".easyui-linkbutton").length===4)
{
alert("Maximum 5 Tabs are allowed");
}
else if ($('#tt').tabs('exists', title))
{
$('#tt').tabs('select', title);
}
else {
var content = '<iframe scrolling="auto" frameborder="0" src="'+url+'" style="width:100%;height:100%;"></iframe>';
$('#tt').tabs('add',{
title:title,
content:content,
closable:true
});
}
}
<link rel="stylesheet" type="text/css" href="http://www.jeasyui.com/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="http://www.jeasyui.com/easyui/themes/icon.css">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="http://www.jeasyui.com/easyui/jquery.easyui.min.js"></script>
<div style="margin-bottom:10px" class="tabs">
tab1
tab2
tab3
tab4
tab5
tab6
tab7
</div>
<div id="tt" class="easyui-tabs" style="width:400px;height:250px;">
<div title="Home">
</div>
</div>
Expect that only 5 Tab-panes open although user tries to open using 6th button. User need to be alerted with a message.
There is one minor change in your code
I changed this line
if($('.tabs-wrap').find('ul').children().length===4)
to this
if($('.tabs-wrap').find('ul').children().length > 5)
and it worked
here is your example
function addTab(title, url) {
var tabs = $(".tabs"),
tabsContent = tabs.children("a");
if ($('.tabs-wrap').find('ul').children().length > 5)
alert("Maximum 5 Tabs are allowed");
else if ($('#tt').tabs('exists', title))
$('#tt').tabs('select', title);
else {
var content = '<iframe scrolling="auto" frameborder="0" src="' + url + '" style="width:100%;height:100%;"></iframe>';
$('#tt').tabs('add', {
title: title,
content: content,
closable: true
});
}
}
<link rel="stylesheet" type="text/css" href="http://www.jeasyui.com/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="http://www.jeasyui.com/easyui/themes/icon.css">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="http://www.jeasyui.com/easyui/jquery.easyui.min.js"></script>
<div style="margin-bottom:10px" class="tabs">
tab1
tab2
tab3
tab4
tab5
tab6
tab7
</div>
<div id="tt" class="easyui-tabs" style="width:400px;height:250px;">
<div title="Home">
</div>
</div>
hope it works

I have a jquery issue. I have two divs showing and hiding. Both are set to refresh but one is overriding it

I have a jquery issue I have two divs showing and hiding and both are set to refresh but one is over riding the other. I am not sure why the load1 were div1 is at keeps overriding the load2 div2. so when i click on button completed the received div is automatically refreshing and changing the page back to received. I will try to get this on fiddle.
<!DOCTYPE html>
<html>
<head>
<title></title>
<link href="http://localhost/test/assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="http://localhost/test/assets/css/custom.css" rel="stylesheet">
<link href="http://localhost/test/assets/css/custom_edit.css" rel="stylesheet">
<link href="http://localhost/test/assets/datatables/css/dataTables.bootstrap.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<pre><button class="btn btn-sm btn-primary" id="received">Received</button><button class="btn btn-sm btn-success" id="completed">Completed</button></pre>
<div id="load1">
<div id="div1">
<h3>Received Section</h3>
//code goes here......
</div>
</div>
<div id="load2">
<input type="hidden" id="show_completed" value="1" name="show_completed">
<div id="div2">
<h3>Completed Section</h3>
//code goes here......
</div>
</div>
<footer>
<script src="http://localhost/test/assets/jquery/jquery-3.1.0.min.js"></script>
<script src="http://localhost/test/assets/bootstrap/js/bootstrap.min.js"></script>
<script src="http://localhost/test/assets/datatables/js/jquery.dataTables.min.js"></script>
<script src="http://localhost/test/assets/datatables/js/dataTables.bootstrap.js"></script>
<script type="text/javascript">
var $show_completed = document.getElementById('show_completed');
if($show_completed.value == '0')
{
setInterval(function() {
$("#load1").load(location.href+" #load1>*","");
}, 10000); // seconds to wait, miliseconds
}
else($show_completed.value == '1')
{
setInterval(function() {
$("#load2").load(location.href+" #load2>*","");
}, 100000); // seconds to wait, miliseconds
}
</script>
<script type="text/javascript">
$(document).ready( function () {
$('#div2').fadeOut();
} );
$("#received").on('click', function() {
document.getElementById("show_completed").value='0';
$("#div1").fadeIn();
$("#div2").fadeOut();
});
$("#completed").on('click', function() {
document.getElementById("show_completed").value='1';
$("#div2").fadeIn();
$("#div1").fadeOut();
});
</script>
</footer>
</body>
</html>
Try this... Hope it helps
<!DOCTYPE html>
<html>
<head>
<title></title>
<link href="http://localhost/test/assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="http://localhost/test/assets/css/custom.css" rel="stylesheet">
<link href="http://localhost/test/assets/css/custom_edit.css" rel="stylesheet">
<link href="http://localhost/test/assets/datatables/css/dataTables.bootstrap.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="http://localhost/test/assets/bootstrap/js/bootstrap.min.js"></script>
<script src="http://localhost/test/assets/datatables/js/jquery.dataTables.min.js"></script>
<script src="http://localhost/test/assets/datatables/js/dataTables.bootstrap.js"></script>
</head>
<body>
<pre>
<button class="btn btn-sm btn-primary" id="received">Received</button>
<button class="btn btn-sm btn-success" id="completed">Completed</button>
</pre>
<div id="load1">
<div id="div1">
<h3>Received Section</h3>
//code goes here......
</div>
</div>
<div id="load2">
<input type="hidden" id="show_completed" value="1" name="show_completed">
<div id="div2">
<h3>Completed Section</h3>
//code goes here......
</div>
</div>
<script type="text/javascript">
var $show_completed = document.getElementById('show_completed');
if($show_completed.value == '0'){
setInterval(function() {
$("#load1").load(location.href+" #load1>*","");
}, 10000); // seconds to wait, miliseconds
} else($show_completed.value == '1'){
setInterval(function() {
$("#load2").load(location.href+" #load2>*","");
}, 100000); // seconds to wait, miliseconds
}
</script>
<script type="text/javascript">
$(document).ready( function () {
$('#div2').fadeOut();
});
$("#received").on('click', function() {
document.getElementById("show_completed").value='0';
$("#div1").fadeIn();
$("#div2").fadeOut();
});
$("#completed").on('click', function() {
document.getElementById("show_completed").value='1';
$("#div2").fadeIn();
$("#div1").fadeOut();
});
</script>
</body>
</html>

Javascript is not working in HTML file

I have read through the available links on this topic and they haven't helped.
I'm trying to get the following code to run. The "menu.html" loads the "world.html" in a div on another page, and the HTML comes up, but not the JavaScript.
At first I had the JS in a separate file, but when it wasn't running I moved it into "world.html", but it didn't fix the problem. I have also tried referencing jQuery.
This is menu.html:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="layout.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="contact.js"></script>
<script src="preparePage.js"></script>
</head>
<body>
<a id="infoButton" class="infoButton" href="info.html"></a>
<a id="bodyButton" class="bodyButton" href="body.html"></a>
<a id="enterButton" class="enterButton" onclick="preparePage(); return false;"></a>
<a id="leaveButton" class="leaveButton" href="leave.html"></a>
<a id="contactButton" class="contactButton" onclick="contact(); return false;"></a>
</body>
<footer>
</footer>
</html>
And preparePage.js, which gets rid of the menu and loads world.html:
function preparePage() {
document.getElementById("box").style.backgroundImage = "none";
$("#infoButton").fadeOut("slow");
$("#bodyButton").fadeOut("slow");
$("#leaveButton").fadeOut("slow");
$("#contactButton").fadeOut("slow");
$("#box").load("world.html", function enter() {
$("#enterButton").fadeOut("slow");
});
}
And last but not least, world.html:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function wut() {
window.alert("owo");
}
</script>
</head>
<body onload="wut(); return false;">
mhfkhgfhtfjhfjj<br><br>
<canvas id="gameBox" width="1000" height="500" style="background-color:#ffffff;"></canvas>
</body>
<footer>
</footer>
</html>
EDIT: Also including launchpad.html, which is the page containing the div in which menu.html and world.html load:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="layout.css">
<link rel="stylesheet" type="text/css" href="menu.css">
</head>
<body onload="openGame(); return false;">
<div id="cloud"></div>
<div id="box" class="box"></div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="openGame.js"></script>
</body>
<footer>
</footer>
</html>
And openGame.js, which changes the shape of #box and loads menu.html:
function openGame() {
$("#cloud").fadeOut("fast");
$("#box").animate({
height: '750px',
width: '1700px',
top: '100px',
left: '100px',
padding: '0px'
});
$("#box").load("menu.html");
document.getElementById("box").style.backgroundImage = "url('Images/menuBackground.png')";
}
I would use JQuery for the on-click events, and also make sure that all of the element id's that you reference in your script are present in the page. Another thing to check is that your scripts are loading properly, the letter casing of the file name is important on Linux servers.
HTML:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="layout.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="contact.js"></script>
<script src="preparePage.js"></script>
</head>
<body>
<ul id="menu">
<li><a id="infoButton" class="infoButton" href="info.html">test1</a></li>
<li><a id="bodyButton" class="bodyButton" href="body.html">test2</a></li>
<li><a id="enterButton" class="enterButton">test3</a></li>
<li><a id="leaveButton" class="leaveButton" href="">test4</a></li>
<li><a id="contactButton" class="contactButton">test5</a></li>
</ul>
<div id="box" style="width:500px; height:500px; background-color:#FFF; background-image:url(http://cdn.sstatic.net/Sites/stackoverflow/img/apple-touch-icon#2.png?v=73d79a89bded&a);">
test box
</div>
<footer>
</footer>
</body></html>
Javascript:
$( document ).ready(function() {
$( "#enterButton" ).click(function() {
document.getElementById("box").style.backgroundImage = "none";
$("#infoButton").fadeOut("slow");
$("#bodyButton").fadeOut("slow");
$("#leaveButton").fadeOut("slow");
$("#contactButton").fadeOut("slow");
$("#box").load("/zalun/VkCyH/app.html", function enter() {
$("#enterButton").fadeOut("slow");
})
})
});
Live example: https://jsfiddle.net/ucjs77L8/
Apart from the obvious fact that you don't have an element with the id box, please realise that the jQuery load method will not trigger the onload callback that you have defined in world.html. So you'd need to call that yourself.
So fix two things:
define box, e.g.
<div id="box"></div>
call wut(), from menu.html:
$("#box").load("world.html", function enter() {
wut();
$("#enterButton").fadeOut("slow");
});
The onload= in world.html has no effect when loaded like this, because to the browser there is only one document, which already has loaded. So, there is no second load event triggering.
Alternatively you could just add a script in world.html, near the end just before the closing </body> tag, which will run:
<script>
wut();
</script>

How do i embed mpeg-dash live video stream using this code?

I have a working code to embed a Wowza manifest.mpd live video stream into a MPEG-dash player on a website but in order for it to work, you have to put in the URL to the manifest file and then click connect.
I need to get rid of the input box and just have it load the manifest file automatically on page load.
I've tried adding the src to the video tag as the manifest URL but it doesn't load. I'm guessing that when clicking connects to load the manifest file the script is also doing something else but with no scripting knowledge I don't know what.
Can anyone suggest what I would change the code to so that it will load the script as it does when you click connect but automatically on page load?
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>MPEG-DASH Player - Live Video Streaming</title>
<script language="javascript">AC_FL_RunContent = 0;</script>
<link rel="stylesheet" href="css/screen.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="css/wowza.css" type="text/css" />
<!-- Libraries -->
<script src="app/lib/jquery/js/jquery-1.8.3.min.js"></script>
<script src="app/lib/jquery/js/jquery-ui-1.9.2.custom.min.js"></script>
<!-- https://github.com/kriskowal/q -->
<script src="app/lib/q.js"></script>
<!-- https://github.com/creynders/dijon-framework -->
<script src="app/lib/dijon.js"></script>
<!-- Misc Libs -->
<script src="app/lib/xml2json.js"></script>
<script src="app/lib/objectiron.js"></script>
<script src="app/lib/long.js"></script>
<script src="app/lib/Math.js"></script>
<!-- Player -->
<script src="app/js/streaming/MediaPlayer.js"></script>
<script src="app/js/streaming/Context.js"></script>
<script src="app/js/streaming/ErrorHandler.js"></script>
<script src="app/js/streaming/Capabilities.js"></script>
<script src="app/js/streaming/Debug.js"></script>
<script src="app/js/streaming/VideoModel.js"></script>
<script src="app/js/streaming/vo/SegmentRequest.js"></script>
<script src="app/js/streaming/ManifestLoader.js"></script>
<script src="app/js/streaming/ManifestUpdater.js"></script>
<script src="app/js/streaming/ManifestModel.js"></script>
<script src="app/js/streaming/MediaSourceExtensions.js"></script>
<script src="app/js/streaming/SourceBufferExtensions.js"></script>
<script src="app/js/streaming/VideoModelExtensions.js"></script>
<script src="app/js/streaming/BufferExtensions.js"></script>
<script src="app/js/streaming/FragmentController.js"></script>
<script src="app/js/streaming/AbrController.js"></script>
<script src="app/js/streaming/FragmentLoader.js"></script>
<script src="app/js/streaming/Stream.js"></script>
<script src="app/js/streaming/BufferController.js"></script>
<script src="app/js/streaming/rules/SwitchRequest.js"></script>
<script src="app/js/streaming/rules/DownloadRatioRule.js"></script>
<script src="app/js/streaming/rules/InsufficientBufferRule.js"></script>
<script src="app/js/streaming/rules/LimitSwitchesRule.js"></script>
<script src="app/js/streaming/rules/BaseRulesCollection.js"></script>
<!-- Metrics -->
<script src="app/js/streaming/vo/MetricsList.js"></script>
<script src="app/js/streaming/MetricsModel.js"></script>
<script src="app/js/streaming/vo/metrics/BufferLevel.js"></script>
<script src="app/js/streaming/vo/metrics/HTTPRequest.js"></script>
<script src="app/js/streaming/vo/metrics/PlayList.js"></script>
<script src="app/js/streaming/vo/metrics/RepresentationSwitch.js"></script>
<script src="app/js/streaming/vo/metrics/TCPConnection.js"></script>
<script src="app/js/streaming/vo/metrics/DroppedFrames.js"></script>
<!-- Dash -->
<script src="app/js/dash/Dash.js"></script>
<script src="app/js/dash/DashContext.js"></script>
<script src="app/js/dash/vo/Segment.js"></script>
<script src="app/js/dash/DashParser.js"></script>
<script src="app/js/dash/DashHandler.js"></script>
<script src="app/js/dash/BaseURLExtensions.js"></script>
<script src="app/js/dash/FragmentExtensions.js"></script>
<script src="app/js/dash/DashManifestExtensions.js"></script>
<script src="app/js/dash/DashMetricsExtensions.js"></script>
<script src="app/js/dash/DashMetricsConverter.js"></script>
<!-- App -->
<!--script src="app/js/main.js"></script-->
<!-- Framework CSS -->
<link rel="stylesheet" href="css/screen.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="css/wowza.css" type="text/css" />
<script>
function supports_media_source()
{
"use strict";
var hasWebKit = (window.WebKitMediaSource !== null && window.WebKitMediaSource !== undefined),
hasMediaSource = (window.MediaSource !== null && window.MediaSource !== undefined);
return (hasWebKit || hasMediaSource);
}
</script>
</head>
<body>
<div class="container">
<!-- HEADER -->
<div class="span-18">
<h1>Live Video Streaming</h1>
<h2>MPEG-DASH Player</h2>
</div>
<div class="span-6 last">
<img src="img/wowza-logo_1024.png" class="logo" style="height:72px;width:205px" />
</div>
<hr class="heading">
<!-- END HEADER -->
<!-- EXAMPLE PLAYER: WIDTH of this player should be 630px, height will vary depending on the example-->
<div class="span-16">
<div id="supported" style="display:none">
<div>
<style>
video {
background-color: #000000;
}
</style>
<video id="videoObj" x-webkit-airplay="allow" controls alt="Example File" width="630" height="354" onerror="failed(event)" src="http://undergroundsoundz.com:1935/uszlive/myStream/manifest.mpd"></video>
</div>
<table>
<tr>
<td>
<button id="playObj" type="button" style="width:50px" onclick="JavaScript:playControl()" disabled="disabled">Pause</button>
</td>
</tr>
<tr>
<td align="right">
<b>Stream:</b>
</td>
<td>
<input id="connectStr" size = "56" type="text" placeholder="" value="http://undergroundsoundz.com:1935/uszlive/myStream/manifest.mpd"/>
<button id="connectObj" type="button" style="width:80px" onclick="JavaScript:connect()">Connect</button>
</td>
</tr>
<tr>
<td align="right">
<b>Status:</b>
</td>
<td>
<label id="statusStr" size = "100" type="text" placeholder="" value="">Disconnected</label>
</td>
</tr>
</table>
</div>
<div id="debug_log" style="height: 425px; width: 630px; overflow: auto; clear: both;">
</div>
<script>
if ( supports_media_source() ) {
supported.style.display="";
videoObj.style.display="";
}
else {
notsupported.style.display="";
}
var player;
function connect()
{
if(connectObj.textContent == "Disconnect") {
if(player!=null)
player.stop();
videoObj.src = null;
videoObj.load();
connectObj.textContent = "Connect";
playObj.disabled = "disabled";
playObj.textContent = "Pause";
statusStr.textContent = "Disconnected";
}
else {
connectObj.textContent = "Disconnect";
playObj.disabled = "";
playObj.textContent = "Pause";
statusStr.textContent = "Playing";
var video = document.querySelector("video"),
context = new Dash.di.DashContext();
player = new MediaPlayer(context);
player.startup();
debug = player.debug;
//debug.init(console);
player.autoPlay = true;
player.attachView(video);
player.setIsLive(true);
player.attachSource(connectStr.value);
}
}
function playControl() {
if (videoObj.paused == false) {
videoObj.pause();
statusStr.textContent = "Paused";
playObj.textContent = "Play";
}
else {
videoObj.play();
statusStr.textContent="Playing";
playObj.textContent = "Pause";
}
}
function failed(e) {
// video playback failed - show a message saying why
switch (e.target.error.code) {
case e.target.error.MEDIA_ERR_ABORTED:
statusStr.textContent='You aborted the video playback.';
break;
case e.target.error.MEDIA_ERR_NETWORK:
statusStr.textContent='A network error caused the video download to fail part-way.';
break;
case e.target.error.MEDIA_ERR_DECODE:
statusStr.textContent='The video playback was aborted due to a corruption problem or because the video used features your browser did not support.';
break;
case e.target.error.MEDIA_ERR_SRC_NOT_SUPPORTED:
statusStr.innerHTML= 'The video could not be loaded, either because the server or network failed or because the format is not supported.<br/>';
statusStr.innerHTML+= '<span style="color:red;">Please close all tabs and then try running the appropriate <span style="font-style:italic;">LaunchDashPlayer</span> script for your system in your \"examples/LiveVideoStreaming/MPEGDASHPlayer\" folder.</span>';
break;
default:
statusStr.textContent = 'An unknown error occurred.';
break;
}
}
</script>
</div>
</div>
</body>

Custom function not showing JQuery plugin

I'm a newbie in Jquery. I'm trying to print text on a document dynamically. I have a JavaScript function that is supposed to display images using the jQuery prettyphoto plugin. My function does not show the images but when I paste the code on a html file it works fine. Please help. A sample of my code is here.
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="./index.css" type="text/css">
<script type="text/javascript" charset="utf-8" src="jquery-1.6.4.min.js"></script>
<script type="text/javascript" charset="utf-8" src="spin.min.js"></script>
<script type="text/javascript" charset="utf-8" src="custom-functions.js"></script>
<link rel="stylesheet" href="./prettyPhoto/css/prettyPhoto.css" type="text/css">
<script type="text/javascript" src="./prettyPhoto/js/jquery.prettyPhoto.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
$("a[rel^='prettyPhoto_related-content-images']").prettyPhoto({theme:'facebook'});
});
function showImages()
{
var stringData = '';
stringData = stringData + '<div id="related-content-images" >Related to this: <br/>'+
'<img id="not-hidden" src="images/sample-album-2.jpg" alt="" title="">'+
'<img id="related-images" src="images/sample-album-3.jpg" alt="" title="">'+
'<img id="related-images" src="images/sample-album-4.jpg" alt="" title=""></div>';
document.getElementById("content").innerHTML=''+stringData+'';
}
</script>
</head>
<body>
<div id="header"><div id="app-logo-image">
<img src="images/app-logo.png" id="app-logo"/></div>
<div id="header-form">
<input type="search" id="search-text-box" name="search-text-box" placeholder="Search">
<input type="submit" id="search-button" name="" value="Search">
</div>
</div>
<div id="container">
<div id="sub-header-menu">
<div id="music-albums">
<img src="images/music-albums-icon.png" id="music-albums-image"; onclick="fetch('music-albums');"/></div>
<div id="genres-icon">
<img src="images/genres-icon.png" id="genres-icon-image"onclick="fetch('music-genres');"/></div>
<div id="artist-icon">
<img src="images/artists-icon.png" id="artist-icon-image"onclick="fetch('music-artists');"/></div>
<div id="home-icon">
<img src="images/home-button.png" id="home-icon-image"/></div>
</div>
<div id="content" style="left:0%;">
click me
</div>
</div>
</body>
</html>
Your showImages function isn't executed until the link is clicked, however the prettyPhoto initialisation is only run once when the document finishes loading, and since showImages hasn't been run yet prettyPhotos can't find and enhance those images.
If you add this to the end of showImages everything should work:
$('#content a').prettyPhoto({theme:'facebook'});

Categories

Resources