JavaScript

RSS for tag

Discuss the JavaScript programing language.

JavaScript Documentation

Posts under JavaScript tag

65 Posts
Sort by:
Post not yet marked as solved
7 Replies
1.6k Views
I am currently facing an issue with PWA (Progressive Web App) push notifications on iOS and would greatly appreciate your assistance in resolving it. The problem I am experiencing is that when attempting to open a specific link from the notificationclick method using clients.openWindow('/messages'), the expected redirection to the "messages" page does not occur. Instead, the PWA opens without navigating to the desired destination. I want to emphasize that this issue is unique to iOS devices. If you have encountered a similar issue or have any suggestions on how to resolve it, please share your thoughts. Thank you in advance for your support and valuable suggestions.
Posted
by
Post not yet marked as solved
2 Replies
999 Views
We have been testing universal links and detected the following: Assuming there is an HTML with embedded JS that redirects to the universal link. **Direct redirection --> WORKS OK ** window.location.href = "https://my-universal-link?data=abc"; Redirection with timeOut or Interval --> NOT WORKING (go to default WEB) setTimeout(function () { window.location.href = "https://my-universal-link?data=abc"; }, 2000); setInterval(function () { window.location.href = "https://my-universal-link?data=abc"; }, 2000);
Posted
by
Post not yet marked as solved
0 Replies
785 Views
I am having a video chat application using react js in the frontend and i have one SFU server which is based on Node js with WRTC library for supporting webRTC apis in the server side(M87). App.js import React, { useState, useRef, useEffect, useCallback } from "react"; import io from "socket.io-client"; import Video from "./Components/Video"; import { WebRTCUser } from "./types"; const pc_config = { iceServers: [ // { // urls: 'stun:[STUN_IP]:[PORT]', // 'credentials': '[YOR CREDENTIALS]', // 'username': '[USERNAME]' // }, { urls: "stun:stun.l.google.com:19302", }, ], }; const SOCKET_SERVER_URL = "https://192.168.132.29:8080"; const App = () => { const socketRef = useRef<SocketIOClient.Socket>(); ...... .......... const createReceiverPeerConnection = useCallback((socketID: string) => { try { const pc = new RTCPeerConnection(pc_config); // add pc to peerConnections object receivePCsRef.current = { ...receivePCsRef.current, [socketID]: pc }; pc.onicecandidate = (e) => { if (!(e.candidate && socketRef.current)) return; console.log("receiver PC onicecandidate"); socketRef.current.emit("receiverCandidate", { candidate: e.candidate, receiverSocketID: socketRef.current.id, senderSocketID: socketID, }); }; pc.oniceconnectionstatechange = (e) => { console.log(e); }; pc.ontrack = (e) => { console.log("ontrack success"); setUsers((oldUsers) => oldUsers .filter((user) => user.id !== socketID) .concat({ id: socketID, stream: e.streams[0], }) ); }; // return pc return pc; } catch (e) { console.error(e); return undefined; } }, []); ...... ............ return ( <div> <video style={{ width: 240, height: 240, margin: 5, backgroundColor: "black", }} muted ref={localVideoRef} autoPlay /> {users.map((user, index) => ( <Video key={index} stream={user.stream} /> ))} </div> ); }; export default App; server.js let http = require("http"); let express = require("express"); let cors = require("cors"); let socketio = require("socket.io"); let wrtc = require("wrtc"); const fs = require("fs"); let https = require("https"); const port=8080; const options = { key: fs.readFileSync("../cert/cert.priv.key"), cert: fs.readFileSync("../cert/cert.chain.pem"), }; const app = express(); const server = https.createServer(options, app); app.use(cors()); let receiverPCs = {}; let senderPCs = {}; let users = {}; let socketToRoom = {}; const pc_config = { iceServers: [ // { // urls: 'stun:[STUN_IP]:[PORT]', // 'credentials': '[YOR CREDENTIALS]', // 'username': '[USERNAME]' // }, { urls: "stun:stun.l.google.com:19302", }, ], }; const isIncluded = (array, id) => array.some((item) => item.id === id); const createReceiverPeerConnection = (socketID, socket, roomID) => { const pc = new wrtc.RTCPeerConnection(pc_config); if (receiverPCs[socketID]) receiverPCs[socketID] = pc; else receiverPCs = { ...receiverPCs, [socketID]: pc }; pc.onicecandidate = (e) => { //console.log(`socketID: ${socketID}'s receiverPeerConnection icecandidate`); socket.to(socketID).emit("getSenderCandidate", { candidate: e.candidate, }); }; pc.oniceconnectionstatechange = (e) => { //console.log(e); }; pc.ontrack = (e) => { if (users[roomID]) { if (!isIncluded(users[roomID], socketID)) { users[roomID].push({ id: socketID, stream: e.streams[0], }); } else return; } else { users[roomID] = [ { id: socketID, stream: e.streams[0], }, ]; } socket.broadcast.to(roomID).emit("userEnter", { id: socketID }); }; return pc; }; const createSenderPeerConnection = ( receiverSocketID, senderSocketID, socket, roomID ) => { const pc = new wrtc.RTCPeerConnection(pc_config); if (senderPCs[senderSocketID]) { senderPCs[senderSocketID].filter((user) => user.id !== receiverSocketID); senderPCs[senderSocketID].push({ id: receiverSocketID, pc }); } else senderPCs = { ...senderPCs, [senderSocketID]: [{ id: receiverSocketID, pc }], }; pc.onicecandidate = (e) => { //console.log(`socketID: ${receiverSocketID}'s senderPeerConnection icecandidate`); socket.to(receiverSocketID).emit("getReceiverCandidate", { id: senderSocketID, candidate: e.candidate, }); }; pc.oniceconnectionstatechange = (e) => { //console.log(e); }; ... ...... const closeReceiverPC = (socketID) => { if (!receiverPCs[socketID]) return; receiverPCs[socketID].close(); delete receiverPCs[socketID]; }; const closeSenderPCs = (socketID) => { if (!senderPCs[socketID]) return; senderPCs[socketID].forEach((senderPC) => { senderPC.pc.close(); const eachSenderPC = senderPCs[senderPC.id].filter( (sPC) => sPC.id === socketID )[0]; if (!eachSenderPC) return; eachSenderPC.pc.close(); senderPCs[senderPC.id] = senderPCs[senderPC.id].filter( (sPC) => sPC.id !== socketID ); }); delete senderPCs[socketID]; }; const io = socketio.listen(server); io.sockets.on("connection", (socket) => { socket.on("joinRoom", (data) => { try { let allUsers = getOtherUsersInRoom(data.id, data.roomID); io.to(data.id).emit("allUsers", { users: allUsers }); } catch (error) { console.log(error); } }); socket.on("senderOffer", async (data) => { try { socketToRoom[data.senderSocketID] = data.roomID; let pc = createReceiverPeerConnection( data.senderSocketID, socket, data.roomID ); await pc.setRemoteDescription(data.sdp); let sdp = await pc.createAnswer({ offerToReceiveAudio: true, offerToReceiveVideo: true, }); await pc.setLocalDescription(sdp); socket.join(data.roomID); io.to(data.senderSocketID).emit("getSenderAnswer", { sdp }); } catch (error) { console.log(error); } }); socket.on("senderCandidate", async (data) => { try { let pc = receiverPCs[data.senderSocketID]; await pc.addIceCandidate(new wrtc.RTCIceCandidate(data.candidate)); } catch (error) { console.log(error); } }); ..... ......... startServer(port); function startServer(port) { server.listen(port, () => { console.log(`[INFO] Server app listening on port ${port}`); }); }
Posted
by
Post not yet marked as solved
0 Replies
519 Views
I'm trying to read the clipboard data using the navigator.clipboard.readText() in the button click handler: <body> <h1>How to paste text</h1> <p><button type=button>Paste</button></p><textarea></textarea> <script> const pasteButton = document.querySelector("button"); pasteButton.addEventListener("click", (async () => { try { const e = await navigator.clipboard.readText(); document.querySelector("textarea").value += e; console.log("Text pasted.") } catch (e) { console.log("Failed to read clipboard. Using execCommand instead."); document.querySelector("textarea").focus(); const t = document.execCommand("paste"); console.log("document.execCommand result: ", t) } })); </script> </body> We can use the following link to check the demo page using the above code: https://web.dev/patterns/clipboard/paste-text/demo.html The demo page works fine when clicking the Paste button on the Chrome browser. But, it shows the Paste menu when clicking the Paste button on the Safari browser. Only when clicking the Paste menu on the Safari browser, the clipboard data is pasted into the text box. So, I'd like to know how to hide the "Paste" menu on Safari browser when using navigator.clipboard.readText() in the button click handler. Thanks.
Posted
by
Post not yet marked as solved
0 Replies
426 Views
We have a website running on Angular/CLI version 11.0.5. On iOS devices running iOS 17, we are encountering an issue where, after logging into our website, the screen becomes unresponsive, and no actions can be performed. The only functionality that remains is scrolling. This issue is specific to iOS 17; everything was working smoothly on iOS 16.6. In the browser console, we are seeing the following errors: ERROR: TypeError: e.reduceRight is not a function. (In 'e.reduceRight((e,t)=&gt;new P(e,t),this.backend)', 'e.reduceRight' is undefined) It's worth noting that this errors were also present in iOS 16.6, but the website was functioning correctly on those devices. However, in iOS 17, after a page refresh, the user can log in, but all subsequent pages become unresponsive. Before logging in, functions like signup and password reset work as expected. We are unsure about the changes made in iOS 17 that could be causing this issue.
Posted
by
Post not yet marked as solved
0 Replies
369 Views
I am trying to locate information or documentation on how to pull in photos from the iCloud Shared Albums, but have not been able to find anything yet. Dakboard is currently doing it so I know it is possible, but I cannot find an API or any documentation covering how to access the photos in a Shared Album for incorporation into web applications. Can anyone help?
Posted
by
Post not yet marked as solved
0 Replies
568 Views
In My PWA app I am using camera of getUserMedia() and html audio tags, So In my app I am using videos audios and camera based on requirements, so When I have updated iOS17 I have stared facing below issue. When I am loading camera after premission given. my audios are playing in ear speaker and not in media speaker only for ios17, older ios versions it is working fine. I am using javascript, angular, ionic with html5 css for developing my app. Please provide solution.
Posted
by
Post not yet marked as solved
0 Replies
546 Views
In my PWA app, I utilize the getUserMedia() API for accessing the camera and also employ HTML audio tags to handle various types of media content. However, since updating to iOS 17, I've encountered an issue where, after granting permission for camera access, audio playback occurs through the earpiece instead of the media speaker. This problem is specific to iOS 17; earlier iOS versions work as expected. My app is developed using a stack that includes JavaScript, Angular, Ionic, HTML5, and CSS. Can you please provide guidance or a solution to address this issue and ensure that audio plays through the media speaker when using the camera on iOS 17?
Posted
by
Post not yet marked as solved
1 Replies
415 Views
One time title was showing below the MarkerAnnotation and I noticed, that once it disappeared and now it is showing inside the marker if you click on it. Is it possible to move it back and show it below the marker? The field, that I am using for this purpose is called "title" navigator.userAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36
Posted
by
Post not yet marked as solved
1 Replies
1.5k Views
Recently I noticed that users with Safari 17 have some troubles using my website. I found out that the problem affects only users who use Safari in a private mode. After I dug deeper I realised that for some reason when I execute "window.location" for these users, query parameters do not present there even though they are actually present in the URL. For example, user is on the URL https://mywebsite.com/?code=TULEnfW1zRlqazI7XhM_QV7mxqPr-bV&state=5c5dbb2a-2332-4db7-a657-d2dc713d3e67 But the "window.location.search" returns an empty string. Also, the issue is only reproduced when user is actually redirected to the "broken" page, but it works fine if the user opens the page in a new tab. Issue is reproduced on both iOS and MacOS. I have a suspicion that the issue is somehow related to the recently added feature which prevents cross-site tracking, however, disabling that feature did not help. Does anyone aware of any recent changes to the behaviour of "window.location" in Safari? Thanks!
Posted
by
Post not yet marked as solved
2 Replies
627 Views
With a physical iPhone attached to the dev tools on my laptop, the memory usage of this web page https://nypost.com/2023/10/11/australian-swimmers-almost-walk-into-shark-as-it-swims-close-to-shore/ consistently grows until it reaches the memory limit of the device (in my case, about 1.5GB) The safari dev tools has a memory profiler timeline which breaks down memory usage into categories including "Javascript", "Layers", and "Page"; is there a way to break these down further to individual scripts/resources? I have also tried looking at the Javascript allocations profiler, but the computed heap size reported in its snapshots never comes anywhere close to the 700+ MB of "JavaScript" memory usage reported by the Memory profiler.
Posted
by
Post not yet marked as solved
0 Replies
343 Views
Hi guys I'm developing an extension for Safari using web browser api but Safari does not support management object and getSelft() function. Does anyone know how to check if the extension is installed in development mode? window.browser.management.getSelf(({ installType }) => { if(installType === "development") { // Do some stuff... } })
Posted
by
Post not yet marked as solved
1 Replies
649 Views
I have a website that makes heavy use of the web audio API, the site appears to be broken for all users who have upgraded to iOS 17 (I have verified it no longer works for 17.0.3 and does work for 16.3.1 It also works fine in macOS Safari and all other common desktop browsers that I have tested). I've created a simple test case page here to illustrate the problem: https://oldtime.radio/audio_test.html - clicking 'Play' downloads and plays audio in older iOS but nothing is played for iOS 17. There are no errors in the console so not much to go on. Is this a known bug. Code reproduced below in case folks don't want to click through to an unknown website: const btn = document.getElementById('btn'); btn.addEventListener('click', function() { const audio = new Audio(); audio.crossOrigin = "anonymous"; const AudioContext = window.AudioContext || window.webkitAudioContext, audioCtx = new AudioContext(), audioSrc = audioCtx.createMediaElementSource(audio); audioSrc.connect(audioCtx.destination); audio.addEventListener('canplaythrough', () => { audio.play(); }); audio.src = 'https://archive.org/download/Old_Radio_Adverts_01/OldRadio_Adv--1957_Chevrolet.mp3'; audio.load(); });
Posted
by
Post not yet marked as solved
0 Replies
528 Views
If you refresh the page after initially granting location permissions, you will be prompted for location permissions again and will need to grant permission again. Currently this only occurs on iOS. Is there a way? I launched that web from app and the Safari settings didn't fix the issue. What should I do about this problem? The tested iOS versions are 16.2 and 17. This is the code implemented when retrieving location information. <script> var options = { timeout: 15000, enableHighAccuracy: true, maximumAge: 86400000, }; function success(pos) { var crd = pos.coords; alert('Your current position is:'); alert(`Latitude : `+crd.latitude); alert(`Longitude: `+crd.longitude); }; function error(err) { alert(`ERROR(): `+err.message); }; navigator.geolocation.getCurrentPosition(success, error, options); </script>
Posted
by
Post not yet marked as solved
0 Replies
376 Views
If you refresh the page after initially granting location permissions, you will be prompted for location permissions again and will need to grant permission again. Currently this only occurs on iOS. Is there a way? The tested iOS versions are 16.2 and 17. This is the code implemented when retrieving location information. <script> var options = { timeout: 15000, enableHighAccuracy: true, maximumAge: 86400000, }; function success(pos) { var crd = pos.coords; alert('Your current position is:'); alert(`Latitude : `+crd.latitude); alert(`Longitude: `+crd.longitude); }; function error(err) { alert(`ERROR(): `+err.message); }; navigator.geolocation.getCurrentPosition(success, error, options); </script>
Posted
by
Post not yet marked as solved
0 Replies
753 Views
Hi everyone, I hope this a right place to ask questions like this. I have an app which uses WEBGL scene implemented with three.js. At some point of loading, the app crashes (page reloads), which usually indicates that device ran out of memory reserved for this tab. This webgl scene however is fairly light compared to other scenes that load without any issues. How do I debug this? Is it possible to reallocate more memory before page is loaded, or is there a simple way to reduce memory consumption? I have very limited control over 3d scene, and it doesn't use heavy assets (mostly simple geometry with textures on them)
Posted
by
Post not yet marked as solved
1 Replies
474 Views
Any page that has a JavaScript function named "top()" in it causes JavaScript to fail. The function doesn't need to be called or even contain anything. eg. function top() { } JavaScript just locks up. This affects iOS17.2 and macOS 14.2 If occurs in Safari and any app using WKWebView This is a critical bug that affects sites and apps in the wild. I suggest there is something very wrong with the Javascript engine in general if certain function names can cause such a failure. Does anyone else have other function names that cause this failure?
Posted
by
Post not yet marked as solved
1 Replies
517 Views
on our web pages we have allowed certain sources of scripts though content-security-policy meta tag which is working fine as expected on Chrome browser and on Internet Edge. However there is a script called morosa.top when it inserted in our html page, safari is not able to block it while it was supposed to block. if this script gets executed it start taking screenshots of screen and post it to hacker. Please check this could be a potential issue. [Edited by Moderator]
Posted
by
Post not yet marked as solved
0 Replies
914 Views
Hi Safari team, I am a product manager working for a large content recommendation company. Our JavaScriot SDK is running on more than 9000 leading publishers worldwide and has been certified to be aligned with global legal and privacy regulations and guidelines. We have the following problem: Since the launch of Safari 17 (in iOS, iPadOS, and MacOS) - we can see our JavaScript SDK blocked when the user uses the private browsing mode Safari 17 sometimes identifies our loading and rendering JavaSctipt files as any request/action by our domain to be a tracking activity (we see the JavaScript files in the console tagged with “Blocked connection to known tracker” log) In previous Safari versions, we only got the tracking functionality blocked, allowing our content to render We have the following questions: Can JavaScript running in Safari detect the user has the privacy mode turned on? Was there something specific in Safari 17 “Tracking Protection” functionality that now blocks content rendering on the page in addition to tracking activity? Context: We can run our JavaScript without performing any form of tracking, either directly by my domain or any other 3rd party vendor we are working with. We will render our content without performing any form of tracking or fingerprinting We are already following Apple’s iOS IDFA guidelines. Our iOS SDK, for example, detects and respects when the user opts out from sharing the IDFA on an iOS app running our code. In that case, we show our content without breaching the App Tracking Transparency framework rules. Besides sponsored content, our JavaScript SDK also powers organic recommendations for our clients. With Safari 17 blocking anything in private browsing mode, we see unfair interference with organic engagement. Please let us know if you provide guidance to allow our JavaScript SDK to render content when the user uses the private browsing mode, adhering to the privacy requirements. Thank you for helping! Omri.
Posted
by