PAGEFLIP on AS3 XML can't be seen on IE and FIREFOX - javascript
I have an issue and i want to see if someone can help me...
I'm using a PAGEFLIP downloaded from: http://pageflip.hu/ on this project that is inside of a JOOMLA article: http://estudiantes.iems.edu.mx/index.php?option=com_k2&view=item&id=334
MY ISSUE IS THAT I CAN SEE THE PAGEFLIP ONLY ON CHROME AND SAFARI BUT IT DOESN'T RUN ON IE AND FIREFOX, this is not a problem with compatibility, cause it runs on local on Firefox and IE...
I was searching and i think that the issue comes out when I change the URL... This is the ORIGINAL CODE:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>PageFlip4</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="css/pageflip_scalable.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/swfobject.js"></script>
<script type="text/javascript">
var flashvars = {};
flashvars.XMLFileName = "pageflipdata.xml";
flashvars.DataFolder = "pageflipdata/";
if (swfobject.getQueryParamValue("page")) {
flashvars.StartPage = swfobject.getQueryParamValue("page");
} else {
flashvars.StartPage = "1";
}
flashvars.StartAutoFlip = "true";
flashvars.AutoStart = "true";
var params = {};
params.scale = "noscale";
params.salign = "TL";
params.wmode = "transparent";
params.allowscriptaccess = "always";
params.allowfullscreen = "true";
params.menu = "true";
params.bgcolor = "#FFFFFF";
var attributes = {};
swfobject.embedSWF("pageFlip.swf", "pageflip", "100%", "100%", "10.0.0", false, flashvars, params, attributes);
</script>
<link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />
<script src="js/prototype.js" type="text/javascript"></script>
<script src="js/scriptaculous.js?load=effects" type="text/javascript"></script>
<script src="js/lightbox++.js" type="text/javascript"></script>
<script type="text/javascript">
function GroupDelegate(id) {
var objLink = document.getElementById(id);
Lightbox.prototype.start(objLink);
}
function LightboxDelegate(url,caption) {
var objLink = document.createElement('a');
objLink.setAttribute('href',url);
objLink.setAttribute('rel','lightbox');
objLink.setAttribute('title',caption);
Lightbox.prototype.start(objLink);
}
</script>
</head>
<body>
<div id="pageflip" style="margin: 0;"></div>
<a id="group1" href="pageflipdata/pages/demo_page_A.png" rel="lightbox[demoGroup1]" title="Page A, group Called from PageFlip Hotspot"></a>
<a id="group2" href="pageflipdata/pages/demo_page_B.png" rel="lightbox[demoGroup1]" title="Page B, group Called from PageFlip Hotspot"></a>
<a id="group3" href="pageflipdata/pages/demo_page_C.png" rel="lightbox[demoGroup1]" title="Page C, group Called from PageFlip Hotspot"></a>
</body>
</html>
I can't see it on Firefox and IE When I change the URL from this SCRIPT lines (this is my code online):
<script type="text/javascript">
var flashvars = {};
flashvars.XMLFileName = "pageflipdata.xml";
flashvars.DataFolder = "http://estudiantes.iems.edu.mx/cired/swfs/ae/fl/noumeno/obj/pageflipdata/";
if (swfobject.getQueryParamValue("page")) {
flashvars.StartPage = swfobject.getQueryParamValue("page");
} else {
flashvars.StartPage = "1";
}
flashvars.StartAutoFlip = "true";
flashvars.AutoStart = "true";
var params = {};
params.scale = "noscale";
params.salign = "TL";
params.wmode = "transparent";
params.allowscriptaccess = "always";
params.allowfullscreen = "true";
params.menu = "true";
params.bgcolor = "#FFFFFF";
var attributes = {};
swfobject.embedSWF("http://estudiantes.iems.edu.mx/cired/swfs/ae/fl/noumeno/obj/pageFlip.swf", "pageflip", "100%", "100%", "10.0.0", false, flashvars, params, attributes);
</script>
So, what i think is incorrect is the way i write it, kind of syntax issue.
Somebody has an idea of what can i try to solve this. Thank you so much! ;)
Try giving full path for XML
or can use HTML like
Related
How to do create two different links using javascript
example <a id = "fb" href= "#">Facebook</a> Actually i want if page is Arabic it should be like this href = "www.facebook.com/ar" if page is English href = "www.facebook.com/en"
Maybe this helps let lang = document.documentElement.lang; console.log(lang); let link = document.getElementById("fb"); if(lang == 'ar'){ link.href += '/ar' } else if(lang == 'en'){ link.href += '/en' } <a id="fb" href= "www.facebook.com">Facebook</a>
You can try this => <html lang="en"> <head> <title>Document</title> </head> <body> <a id = "ar">Facebook AR</a> <a id = "en">Facebook EN</a> <script> var ar = document.getElementById("ar").setAttribute("href", "www.facebook.com/ar"); var en = document.getElementById("en").setAttribute("href", "www.facebook.com/en"); </script> </body> </html> but it is better to use like this, if not it may be some console errors var ar = document.getElementById("ar") ? document.getElementById("ar").setAttribute("href", "www.facebook.com/ar") : null; var en = document.getElementById("en") ? document.getElementById("en").setAttribute("href", "www.facebook.com/en") : null;
Selenium: Get code source of innerHTML that doesn't show in 'inspect element'
Good day! I have been looking around the whole internet and I didn't find any problem like mine. I'm trying to get data using selenium from 'https://mobile.bet9ja.com/mobile' I have navigated to the path I needed step by step, till I got to the page I wanted. That page loads a picture, then after some time numbers and data that I'm looking for. My full code is: import requests from bs4 import BeautifulSoup import lxml from selenium import webdriver import selenium from selenium.webdriver.common.keys import Keys import time from selenium.webdriver import ActionChains log_in_url = 'https://mobile.bet9ja.com/mobile/login' driver = webdriver.Chrome('/Users/macbook/Downloads/chromedriver') driver.get(log_in_url) user_name = driver.find_element_by_css_selector("input.form-input[type='text']") password = driver.find_element_by_css_selector("input.form-input[type='password']") log_in_button = driver.find_element_by_tag_name('button') user_name.clear() password.clear() # It needs log in user_name.send_keys('user_name') password.send_keys('password') log_in_button.click() time.sleep(5) try: # Close a pop up window close_pop_up_window = driver.find_element_by_class_name('modal-close') close_pop_up_window.click() except: pass time.sleep(2) league_button = driver.find_element_by_id('iconslider_1549_league_element') league_button.click() time.sleep(6) premiere_legue = driver.find_element_by_class_name('col-xs-6') premiere_legue.click() time.sleep(15) after that I have tried all these codes and they return the same result: html = driver.page_source() and html = driver.execute_script("return document.body.innerHTML") and html = driver.execute_script("return document.getElementsByTagName('html')[0].innerHTML") The result is: <html><head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"><script type="text/javascript" src="https://bam.nr-data.net/1/c95cd51526?a=214311961&v=1167.2a4546b&to=ZlBXZxcAVkEHV0NbDV8aYEEMTlpXEg1dU09cWldaCQQXXglTXlxNWFtRVh1PSFoW&rst=363&ref=https://vsmobile.bet9ja.com/bet9ja-mobile/login/&ap=5&be=322&fe=360&dc=355&perf=%7B%22timing%22:%7B%22of%22:1588686621313,%22n%22:0,%22u%22:310,%22ue%22:310,%22f%22:4,%22dn%22:5,%22dne%22:5,%22c%22:5,%22s%22:95,%22ce%22:187,%22rq%22:187,%22rp%22:301,%22rpe%22:305,%22dl%22:313,%22di%22:355,%22ds%22:355,%22de%22:359,%22dc%22:360,%22l%22:360,%22le%22:361%7D,%22navigation%22:%7B%7D%7D&fp=360&at=ShdUEV8aRU8%3D&jsonp=NREUM.setToken"></script><script src="https://js-agent.newrelic.com/nr-1167.min.js"></script><script type="text/javascript">(window.NREUM||(NREUM={})).loader_config={licenseKey:"c95cd51526",applicationID:"214311961"};window.NREUM||(NREUM={}),__nr_require=function(e,n,t){function r(t){if(!n[t]){var i=n[t]={exports:{}};e[t][0].call(i.exports,function(n){var i=e[t][1][n];return r(i||n)},i,i.exports)}return n[t].exports}if("function"==typeof __nr_require)return __nr_require;for(var i=0;i<t.length;i++)r(t[i]);return r}({1:[function(e,n,t){function r(){}function i(e,n,t){return function(){return o(e,[u.now()].concat(f(arguments)),n?null:this,t),n?void 0:this}}var o=e("handle"),a=e(4),f=e(5),c=e("ee").get("tracer"),u=e("loader"),s=NREUM;"undefined"==typeof window.newrelic&&(newrelic=s);var p=["setPageViewName","setCustomAttribute","setErrorHandler","finished","addToTrace","inlineHit","addRelease"],l="api-",d=l+"ixn-";a(p,function(e,n){s[n]=i(l+n,!0,"api")}),s.addPageAction=i(l+"addPageAction",!0),s.setCurrentRouteName=i(l+"routeName",!0),n.exports=newrelic,s.interaction=function(){return(new r).get()};var m=r.prototype={createTracer:function(e,n){var t={},r=this,i="function"==typeof n;return o(d+"tracer",[u.now(),e,t],r),function(){if(c.emit((i?"":"no-")+"fn-start",[u.now(),r,i],t),i)try{return n.apply(this,arguments)}catch(e){throw c.emit("fn-err",[arguments,this,e],t),e}finally{c.emit("fn-end",[u.now()],t)}}}};a("actionText,setName,setAttribute,save,ignore,onEnd,getContext,end,get".split(","),function(e,n){m[n]=i(d+n)}),newrelic.noticeError=function(e,n){"string"==typeof e&&(e=new Error(e)),o("err",[e,u.now(),!1,n])}},{}],2:[function(e,n,t){function r(e,n){var t=e.getEntries();t.forEach(function(e){"first-paint"===e.name?c("timing",["fp",Math.floor(e.startTime)]):"first-contentful-paint"===e.name&&c("timing",["fcp",Math.floor(e.startTime)])})}function i(e,n){var t=e.getEntries();t.length>0&&c("lcp",[t[t.length-1]])}function o(e){if(e instanceof s&&!l){var n,t=Math.round(e.timeStamp);n=t>1e12?Date.now()-t:u.now()-t,l=!0,c("timing",["fi",t,{type:e.type,fid:n}])}}if(!("init"in NREUM&&"page_view_timing"in NREUM.init&&"enabled"in NREUM.init.page_view_timing&&NREUM.init.page_view_timing.enabled===!1)){var a,f,c=e("handle"),u=e("loader"),s=NREUM.o.EV;if("PerformanceObserver"in window&&"function"==typeof window.PerformanceObserver){a=new PerformanceObserver(r),f=new PerformanceObserver(i);try{a.observe({entryTypes:["paint"]}),f.observe({entryTypes:["largest-contentful-paint"]})}catch(p){}}if("addEventListener"in document){var l=!1,d=["click","keydown","mousedown","pointerdown","touchstart"];d.forEach(function(e){document.addEventListener(e,o,!1)})}}},{}],3:[function(e,n,t){function r(e,n){if(!i)return!1;if(e!==i)return!1;if(!n)return!0;if(!o)return!1;for(var t=o.split("."),r=n.split("."),a=0;a<r.length;a++)if(r[a]!==t[a])return!1;return!0}var i=null,o=null,a=/Version\/(\S+)\s+Safari/;if(navigator.userAgent){var f=navigator.userAgent,c=f.match(a);c&&f.indexOf("Chrome")===-1&&f.indexOf("Chromium")===-1&&(i="Safari",o=c[1])}n.exports={agent:i,version:o,match:r}},{}],4:[function(e,n,t){function r(e,n){var t=[],r="",o=0;for(r in e)i.call(e,r)&&(t[o]=n(r,e[r]),o+=1);return t}var i=Object.prototype.hasOwnProperty;n.exports=r},{}],5:[function(e,n,t){function r(e,n,t){n||(n=0),"undefined"==typeof t&&(t=e?e.length:0);for(var r=-1,i=t-n||0,o=Array(i<0?0:i);++r<i;)o[r]=e[n+r];return o}n.exports=r},{}],6:[function(e,n,t){n.exports={exists:"undefined"!=typeof window.performance&&window.performance.timing&&"undefined"!=typeof window.performance.timing.navigationStart}},{}],ee:[function(e,n,t){function r(){}function i(e){function n(e){return e&&e instanceof r?e:e?c(e,f,o):o()}function t(t,r,i,o){if(!l.aborted||o){e&&e(t,r,i);for(var a=n(i),f=v(t),c=f.length,u=0;u<c;u++)f[u].apply(a,r);var p=s[y[t]];return p&&p.push([b,t,r,a]),a}}function d(e,n){h[e]=v(e).concat(n)}function m(e,n){var t=h[e];if(t)for(var r=0;r<t.length;r++)t[r]===n&&t.splice(r,1)}function v(e){return h[e]||[]}function g(e){return p[e]=p[e]||i(t)}function w(e,n){u(e,function(e,t){n=n||"feature",y[t]=n,n in s||(s[n]=[])})}var h={},y={},b={on:d,addEventListener:d,removeEventListener:m,emit:t,get:g,listeners:v,context:n,buffer:w,abort:a,aborted:!1};return b}function o(){return new r}function a(){(s.api||s.feature)&&(l.aborted=!0,s=l.backlog={})}var f="nr#context",c=e("gos"),u=e(4),s={},p={},l=n.exports=i();l.backlog=s},{}],gos:[function(e,n,t){function r(e,n,t){if(i.call(e,n))return e[n];var r=t();if(Object.defineProperty&&Object.keys)try{return Object.defineProperty(e,n,{value:r,writable:!0,enumerable:!1}),r}catch(o){}return e[n]=r,r}var i=Object.prototype.hasOwnProperty;n.exports=r},{}],handle:[function(e,n,t){function r(e,n,t,r){i.buffer([e],r),i.emit(e,n,t)}var i=e("ee").get("handle");n.exports=r,r.ee=i},{}],id:[function(e,n,t){function r(e){var n=typeof e;return!e||"object"!==n&&"function"!==n?-1:e===window?0:a(e,o,function(){return i++})}var i=1,o="nr#id",a=e("gos");n.exports=r},{}],loader:[function(e,n,t){function r(){if(!x++){var e=E.info=NREUM.info,n=d.getElementsByTagName("script")[0];if(setTimeout(s.abort,3e4),!(e&&e.licenseKey&&e.applicationID&&n))return s.abort();u(y,function(n,t){e[n]||(e[n]=t)}),c("mark",["onload",a()+E.offset],null,"api");var t=d.createElement("script");t.src="https://"+e.agent,n.parentNode.insertBefore(t,n)}}function i(){"complete"===d.readyState&&o()}function o(){c("mark",["domContent",a()+E.offset],null,"api")}function a(){return O.exists&&performance.now?Math.round(performance.now()):(f=Math.max((new Date).getTime(),f))-E.offset}var f=(new Date).getTime(),c=e("handle"),u=e(4),s=e("ee"),p=e(3),l=window,d=l.document,m="addEventListener",v="attachEvent",g=l.XMLHttpRequest,w=g&&g.prototype;NREUM.o={ST:setTimeout,SI:l.setImmediate,CT:clearTimeout,XHR:g,REQ:l.Request,EV:l.Event,PR:l.Promise,MO:l.MutationObserver};var h=""+location,y={beacon:"bam.nr-data.net",errorBeacon:"bam.nr-data.net",agent:"js-agent.newrelic.com/nr-1167.min.js"},b=g&&w&&w[m]&&!/CriOS/.test(navigator.userAgent),E=n.exports={offset:f,now:a,origin:h,features:{},xhrWrappable:b,userAgent:p};e(1),e(2),d[m]?(d[m]("DOMContentLoaded",o,!1),l[m]("load",r,!1)):(d[v]("onreadystatechange",i),l[v]("onload",r)),c("mark",["firstbyte",f],null,"api");var x=0,O=e(6)},{}],"wrap-function":[function(e,n,t){function r(e){return!(e&&e instanceof Function&&e.apply&&!e[a])}var i=e("ee"),o=e(5),a="nr#original",f=Object.prototype.hasOwnProperty,c=!1;n.exports=function(e,n){function t(e,n,t,i){function nrWrapper(){var r,a,f,c;try{a=this,r=o(arguments),f="function"==typeof t?t(r,a):t||{}}catch(u){l([u,"",[r,a,i],f])}s(n+"start",[r,a,i],f);try{return c=e.apply(a,r)}catch(p){throw s(n+"err",[r,a,p],f),p}finally{s(n+"end",[r,a,c],f)}}return r(e)?e:(n||(n=""),nrWrapper[a]=e,p(e,nrWrapper),nrWrapper)}function u(e,n,i,o){i||(i="");var a,f,c,u="-"===i.charAt(0);for(c=0;c<n.length;c++)f=n[c],a=e[f],r(a)||(e[f]=t(a,u?f+i:i,o,f))}function s(t,r,i){if(!c||n){var o=c;c=!0;try{e.emit(t,r,i,n)}catch(a){l([a,t,r,i])}c=o}}function p(e,n){if(Object.defineProperty&&Object.keys)try{var t=Object.keys(e);return t.forEach(function(t){Object.defineProperty(n,t,{get:function(){return e[t]},set:function(n){return e[t]=n,n}})}),n}catch(r){l([r])}for(var i in e)f.call(e,i)&&(n[i]=e[i]);return n}function l(n){try{e.emit("internal-error",n)}catch(t){}}return e||(e=i),t.inPlace=u,t.flag=a,t}},{}]},{},["loader"]);</script> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Adapter</title> <!-- DEPENDENCIES --> <link rel="shortcut icon" href="img/login_favicon.ico"> <link href="https://fonts.googleapis.com/css?family=Ubuntu:400,700,400italic" rel="stylesheet" type="text/css"> <link href="css/sportsbook.css" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Roboto:400,500,700"> <link href="css/demo.css" rel="stylesheet"> <link href="css/loginBetin.css" rel="stylesheet"> <link href="css/login.css" rel="stylesheet"> <link href="plugins/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet"> <script src="plugins/jquery-1.12.4/jquery.min.js"></script> <script src="plugins/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script> <!-- Javascript client-side code --> <script type="text/javascript"> var lang = ""; function openSelection(mode, uri){ var url = "https://vsmobile.bet9ja.com" + uri + (uri.indexOf('?') ? "&mode=" : "?mode=") + mode + "&lang=" + lang; window.location.replace(url); } function backToMain(){ var url = "https://mobile.bet9ja.com/Mobile"; window.location.replace(url); } </script> <script type="text/javascript" src="js/grapi.js"></script> </head> <body> <div class="container" id="product" style="display: none"> </div> <div class="container" id="playarea" style=""> <script> var isLoaded = false; function onLoadIframe(iframe) { if (!isLoaded) { // iframe.src = '?game=league&OTP=98405c34-4f92-4db7-b993-7562953d2604&mode=premier&lang='; // './index-iframe-content.html' + window.location.search; if( iframe.src != "" ) { isLoaded = true; } } else { goBackUrl(); } } eventMethod = window.addEventListener ? "addEventListener" : "attachEvent"; eventer = window[eventMethod]; messageEvent = eventMethod == "attachEvent" ? "onmessage" : "message"; eventer(messageEvent, function (e) { let data = e.data.split('$'); let command = data[0]; if (command == "goHome") { backToMain(); } }, false); </script> <div style="${bet9ja.iframe.style}"> <iframe id="playAreaFrame" onload="onLoadIframe(this)" style=" position:absolute;top:0;left:0;right:0;bottom:0;width:100%;height:100%;border:0; " src="https://vsmobile.bet9ja.com/mobile-1.94.35/themes/?sk=bet9ja&t=644ee448-8fb1-426c-9922-31688a0a85f6&pinHash=53a0d64f55b5986a27e81982ccd000de&pid=14001&v=0&text=Premier&homeUrl=https://mobile.bet9ja.com/Mobile&otp=98405c34-4f92-4db7-b993-7562953d2604&ss=&bl=&vu=0"> </iframe> </div> </div> <script type="text/javascript" charset="utf-8"> $(function() { var input = {"game":"league","OTP":"98405c34-4f92-4db7-b993-7562953d2604","mode":"premier","lang":""}; var u = "98405c34-4f92-4db7-b993-7562953d2604"; var home = ""; //"https://vsmobile.bet9ja.com/bet9ja-mobile/login/"; var params = "&pid=14001&v=0&text=Premier"; var game = "league_premier"; grapi.loggedUser(u,input,home,params,game,true ); }); </script> <script type="text/javascript">window.NREUM||(NREUM={});NREUM.info={"beacon":"bam.nr-data.net","licenseKey":"c95cd51526","applicationID":"214311961","transactionName":"ZlBXZxcAVkEHV0NbDV8aYEEMTlpXEg1dU09cWldaCQQXXglTXlxNWFtRVh1PSFoW","queueTime":0,"applicationTime":5,"atts":"ShdUEV8aRU8=","errorBeacon":"bam.nr-data.net","agent":""}</script> </body></html> I have tried to inspect the webpage using google chrome, and I have noticed that when I inspect the page the first time it shows (Please check the link for a screenshot): Screenshot of the code. The arrow points to the place where the code I need will be and when I inspect it for the second time I get the code I need. I have really invested a lot of time searching for any solutions, but I got nothing. I will be so happy to find a solution here. Thanks a lot
Thanks a lot #Sureshmani and #Anees Ijaz for your comments. So after you suggestions, the solution waas to switch to the iframe, so that's what solved my problem: iframe = driver.find_element_by_id('playAreaFrame') driver.switch_to.frame(iframe) print(driver.page_source) driver.switch_to.default_content() #To switch back to the original content Thanks a lot guys
Uncaught ReferenceError: isApp is not defined
I am getting "Uncaught ReferenceError: isApp is not defined" in the console, I had tried to find solution for this error from long morning but didn't able to get much, both of my isApp.js and mApp.js are saved in folder named as "js", can someone please help me to get out of this thing....thanks in advance //"......isApp.js file code starts from here..............." var iA = function () { var t = this; this.user; var IsInvite = false; this.serverUrl = someLocalhostUrl; //some function - structure of functions is shown below //this.function1 = function(){ //do something //}; //lot of function this.initialize = function () { t.getUser(); var pk = typeof t.user; if (!(typeof t.user === 'object')) { t.user = null; t.setUser(); } }(); }; var isApp = new iA(); //"......isApp.js file code endss here..............." //"......mApp.js file code starts from here..............." var mApp = function () { //var PostUrl = "http://localhost:52015/" var PostUrl = isApp.serverUrl + "/"; var t = this; var u = {}; this.ph, this.loc; var user, Email, UserName; var LoggedIn; this.initiate = function () { u = isApp.getUser(); if (u && u.LoggedIn) { if (window.location.href.indexOf("index") == -1) $.mobile.changePage("index.html#p-start"); //window.location = "index.html#p-home"; } }; //some function - structure of functions is shown below //this.function1 = function(){ //do something //}; //lot of function this.initiate(); }; m = new mApp(); //"......mApp.js file code ends here..............." <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <style> </style> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <!--css starts here--> <link href="css/jquery.mobile-1.4.5.css" rel="stylesheet" /> <link href="css/custom.css" rel="stylesheet" /> <!--css ends here--> <!--js starts here--> <script src="js/jquery.js"></script> <script src="js/jquery.mobile-1.4.5.js"></script> <script src="js/jquery.signalR-2.2.0.min.js"></script> <script src="js/mApp.js"></script> <script src="js/isApp.js"></script> <script src="js/home.js"></script> <!--js ends here--> <!--<script> $(function () { $('.image').click(function () { alert("selection needed"); }); document.getElementById("startDate").valueAsDate = new Date(); }); </script>--> </head> <body> <div data-role="page" id="p-start"> <div data-role="main" class="ui-content ui-responsive ui-body-a"> <div class="align-center"> <h3>Its our Rocking app</h3> <a href="#p-login"> <img src="images/temp-logo.jpg" class="logo" /> </a> </div> </div> </div> </body> </html>
You load your mApp.js file before your isApp.js file and both scripts are executed right away, so naturally the function isn't defined yet when mApp.js is executed. <script src="js/mApp.js"></script> <script src="js/isApp.js"></script>
Changing images using on click with arrays in javascript
When ever I try to click on the image, the image changes but the next image in the array is not displayed <!doctype html> <html> <head> <title> slides </title> <script type="text/javascript"> function nextslide(){ var images = new Array() images[0]= "home.jpg" images[1]= "left.jpg" images[2]= "right.jpg" var currentpic=0 var lastpic= images.lenth-1; if (currentpic =lastpic) { currentpic=0; document.getElementById('slide').src = images[currentpic]; }else { currentpic++; document.getElementById('slide').src = images[currentpic]; } } </script> </head> <body> <img src="home.jpg" id="slide" onclick="nextslide()"> </body> </html> Help would be greatly appreciated. Thank you for the help.
There are several things wrong with your code. Here is the fixed version: <!doctype html> <html> <head> <title>slides</title> <script type="text/javascript"> var images = new Array(); images[0] = "home.jpg"; images[1] = "left.jpg"; images[2] = "right.jpg"; var currentpic = 0; var lastpic = images.length-1; function nextslide() { if (currentpic == lastpic) { currentpic = 0; document.getElementById('slide').src = images[currentpic]; } else { currentpic++; document.getElementById('slide').src = images[currentpic]; } } </script> </head> <body> <img src="home.jpg" id="slide" onclick="nextslide()"> </body> </html> What's wrong? var lastpic= images.lenth-1; You're missing a g in length. if (currentpic =lastpic) To check if var1 is the same as var2, you need to use == instead of = You're missing a couple of semicolons. You should declare currentpic, images, and lastpic outside of your function to make it actually set the image as the next image. To try and debug yourself Always check your browser's developer console for errors.
try this 1.) Specify globallythis variable var currentpic=0; 2.) Change in images.lenth to images.length 3.) Change if (currentpic =lastpic) to if (currentpic ==lastpic) <!doctype html> <html> <head> <title> slides </title> <script type="text/javascript"> var currentpic=0; function nextslide(){ var images = new Array() images[0]= "http://thewowstyle.com/wp-content/uploads/2015/04/Cartoon.jpg" images[1]= "http://vignette2.wikia.nocookie.net/epicrapbattlesofhistory/images/1/10/Penguin-cartoon.png/revision/latest?cb=20141207223335" images[2]= "http://cliparts.co/cliparts/kiK/Byz/kiKByzxoT.jpg" var lastpic= images.length-1; if (currentpic ==lastpic) { currentpic=0; document.getElementById('slide').src = images[currentpic]; }else { currentpic++; document.getElementById('slide').src = images[currentpic]; } } </script> </head> <body> <img src="home.jpg" id="slide" onclick="nextslide()"> </body> </html>
Script Change on Keydown Working Locally, but not on Server
When tested locally the example below works perfectly. It cycles through different jsmovermaps on mouse press, but when I test this on the server it doesn't update the jsmovermap relevant to cursor press. I have uploaded the maps correctly. Any help would be appreciated. Many thanks!!! <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Ireland Map</title> <link type="text/css" rel="stylesheet" href="jquery.qtip.css" /> <link rel="stylesheet" type="text/css" href="style2.css"> </head> <body> <div class="map" id="map"> </div> <script src="jquery-2.1.1.min.js"></script> <script src="raphael-min.js"></script> <script src="jquery.qtip.js"></script> <script src="jsmovermap1.js" id="s1"></script> <script> x=1; //alert(x); document.addEventListener('keydown', function (evt) { if (evt.keyCode === 38) { //alert('The "UP" key is being held down...?'); x=x+1; //alert(x); //script.src = "jsmovermap"+(x)+".js"; var s = document.createElement("script"); s.type = "text/javascript"; s.src = "jsmovermap"+(x)+".js";; s.innerHTML = null; s.id = "map"; document.getElementById("map").innerHTML = ""; document.getElementById("map").appendChild(s); //alert(s.src); } if (evt.keyCode === 40) { //alert('The "DOWN" key is being held down...?'); x=x-1; if(x<1){ x=1} var s = document.createElement("script"); s.type = "text/javascript"; s.src = "jsmovermap"+(x)+".js";; s.innerHTML = null; s.id = "map"; document.getElementById("map").innerHTML = ""; document.getElementById("map").appendChild(s); //alert(x); } }); </script> </body> </html> UPDATE! This is what the console is spitting out after a number of cursor presses. Resource interpreted as Script but transferred with MIME type text/html: "http://jeremiahambrose.com/maptest/Test/jsmovermap23.js".