[Solved] How two different URLs can be forwarded to a single URL with single JavaScript? [closed]

Logical OR (||) works here Do this <script> if(window.location.href == ‘https://www.example.com/2021/05/test-post.html’ || ‘https://www.example.com/2021/05/test-post.html?m=1’) { window.location=”https://www.website.com/2021/12/official-post.html”; } </script> 0 solved How two different URLs can be forwarded to a single URL with single JavaScript? [closed]

[Solved] I want to loop through an array but I don’t want to use for

You can use Array.prototype.map for this. In your case: suspects.map((name) => { let suspectObj= CreateSuspectObjects(name); suspectsList.push(suspectObj); }); If you need the index in the future you can also do: suspects.map((name, idx) => { let suspectObj= CreateSuspectObjects(name); suspectsList.push(suspectObj); }); 4 solved I want to loop through an array but I don’t want to use for

[Solved] Why does not javascript show the output when button is clicked

Check this. function clicked() { var firstname = document.getElementById(“fname”).value; var lastname = document.getElementById(“lname”).value; document.getElementById(“demo”).innerHTML = “Hello ” + firstname + “<br>” + “Your lat name is: ” + lastname; } <div> First Name: <input type=”text” id=”fname” value=””><br><br> Last Name: <input type=”text” id=”lname” value=””> <button onclick=”clicked()”>Submit</button> <p id=”demo”></p> </div> 2 solved Why does not javascript show … Read more

[Solved] How do you inject this code into HTML using Javascript?

var div = document.createElement(“div”); div.setAttribute(“id”, “bar”); div.style.position = “fixed”; div.style.top = “0”; div.style.left = “0”; div.style.height = “50px”; div.style.width = “50px”; div.style.backgroundColor = “#ccc”; document.body.appendChild(div); 0 solved How do you inject this code into HTML using Javascript?

[Solved] How i change array in js get by key [closed]

//perhaps, you probably do it like this : var result = {}; $.each([{id: 1, add_1: “123”, add_2: “add1”}, {id: 2, add_1: “456”, add_2: “add2”} ], function(i, item ){ for(var pro in item ){ result[pro] = result[pro] || []; result[pro].push(item[pro]); } }) console.log(result); 2 solved How i change array in js get by key [closed]

[Solved] move key to sub array js [closed]

You can use .map(), .concat() and Object.assign() methods to get the resultant array: let data = [ {Name: ‘Color’, Data:[{Id: 1, Name: ‘Red’}, {Id: 2, Name: ‘Yellow’}, {Id: 3, Name: ‘Blue’}, {Id: 4, Name: ‘Green’}, {Id: 7, Name: ‘Black’}]}, {Name: ‘Size’, Data:[{Id: 8, Name: ‘S’}, {Id: 11, Name: ‘M’}, {Id: 12, Name: ‘L’}, {Id: 13, … Read more

[Solved] Countdown that can mix various times

Try this https://jsfiddle.net/6bd3L1ew/7/ config = { ‘0’:8, ‘1’:7, ‘2’:6, ‘3’:5, ‘4’:4, ‘5’:3, ‘6’:2, ‘7’:1, ‘8’:1, ‘9’:1, ’10’:1, ’11’:1, ’12’:1, ’13’:1, ’14’:1, ’15’:1, ’16’:1, ’17’:15, ’18’:14, ’19’:13, ’20’:12, ’21’:11, ’22’:10, ’23’:9 } var start = new Date(); function pad(num) { return (“0” + parseInt(num)).substr(-2); } function tick() { var nowTime = new Date().getHours(); var untilTime = … Read more

[Solved] Uncaught TypeError: Not a function

You must include the JS file where the Slider function is defined. Maybe jQuery Slider, from jQueryUI? <link rel=”stylesheet” href=”https://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css”> <script src=”https://code.jquery.com/jquery-1.10.2.js”></script> <script src=”https://code.jquery.com/ui/1.11.4/jquery-ui.js”></script> <link rel=”stylesheet” href=”http://stackoverflow.com/resources/demos/style.css”> Here is the working demo. 12 solved Uncaught TypeError: Not a function

[Solved] Jquery with while loop error [closed]

Try using a function that returns an array instead, and do a loop inside there. $(‘#calendar’).fullCalendar({ editable: true, events: function(){ var arr = []; for(var i = 0; i <= 10; i++){ arr.push({ title: ‘All Day Event’, start: new Date(y,m,i) }); } return arr; }() // <– Here we execute the function, so it evaluates … Read more

[Solved] compare two big strings with javascript [closed]

You can try to use MD5 hashes of long strings. MD5 (Message-Digest algorithm 5) is a widely-used cryptographic hash function with a 128-bit hash value. MD5 has been employed in a wide variety of security applications, and is also commonly used to check the integrity of data. The generated hash is also non-reversable. Data cannot … Read more

[Solved] Optimize cube rendering in threejs

Finally, I get the solution! <script src=”https://cdnjs.cloudflare.com/ajax/libs/three.js/88/three.js”></script> <script> setTimeout(()=>{ s=1.5 k=[] onmousedown=()=>{document.body.requestPointerLock()} onmousemove=(e)=>{ if(document.pointerLockElement===document.body){ vector.xa-=0.01*e.movementX vector.ya-=0.01*e.movementY }} onkeydown=onkeyup=function(e){k[e.keyCode]=e.type==”keydown”} document.body.style.backgroundColor=”black” document.body.style.margin=”0″ scene=new THREE.Scene() camera=new THREE.PerspectiveCamera(75,1,0.1,16);vector={xs:0,ys:0,zs:0,xa:0,ya:0} camera.position.set(0,0,0);renderer=new THREE.WebGLRenderer() document.body.appendChild(renderer.domElement) light=new THREE.PointLight(“rgb(0,127,255)”,1,8);light.position.set(0,0,0);scene.add(light) function render(){ camera.aspect=window.innerWidth/window.innerHeight camera.updateProjectionMatrix() renderer.setSize(innerWidth,innerHeight) requestAnimationFrame(render) renderer.render(scene,camera) } setInterval(()=>{ if(vector.ya<-1){vector.ya=-1} if(1<vector.ya){vector.ya=1} if(k[37]){vector.xa+=0.1} if(k[38]){if(vector.ya<1.2){vector.ya+=0.1}} if(k[39]){vector.xa-=0.1} if(k[40]){if(-1.2<vector.ya){vector.ya-=0.1}} if(k[87]){vector.xs+=0.01*Math.sin(vector.xa)*Math.cos(vector.ya);vector.ys+=0.01*vector.ya;vector.zs+=0.01*Math.cos(vector.xa)*Math.cos(vector.ya)} if(k[83]){vector.xs-=0.01*Math.sin(vector.xa)*Math.cos(vector.ya);vector.ys-=0.01*vector.ya;vector.zs-=0.01*Math.cos(vector.xa)*Math.cos(vector.ya)} if(k[65]){vector.xs+=0.01*Math.sin(vector.xa+Math.PI/2)*Math.cos(vector.ya);vector.ys+=0.01*vector.ya;vector.zs+=0.01*Math.cos(vector.xa+Math.PI/2)*Math.cos(vector.ya)} if(k[68]){vector.xs+=0.01*Math.sin(vector.xa-Math.PI/2)*Math.cos(vector.ya);vector.ys+=0.01*vector.ya;vector.zs+=0.01*Math.cos(vector.xa-Math.PI/2)*Math.cos(vector.ya)} camera.position.x+=vector.xs;vector.xs=vector.xs*9/10 camera.position.y+=vector.ys;vector.ys=vector.ys*9/10 camera.position.z+=vector.zs;vector.zs=vector.zs*9/10 light.position.set(camera.position.x,camera.position.y,camera.position.z) camera.lookAt(new THREE.Vector3(camera.position.x+Math.sin(vector.xa)*Math.cos(vector.ya),camera.position.y+vector.ya,camera.position.z+Math.cos(vector.xa)*Math.cos(vector.ya))) if(s<Math.max(Math.pow(camera.position.x*camera.position.x,1/2),Math.pow(camera.position.y*camera.position.y,1/2),Math.pow(camera.position.z*camera.position.z,1/2))+12){sy=1.5 … Read more

[Solved] Send data to JS when PHP is told to do so

that would be done with Ajax or WEbSockets. WebSocket works by opening a connection channel between the server and users. you can find some websocket Examples Here: http://www.websocket.org/demos.html 1 solved Send data to JS when PHP is told to do so