JavaScript

RSS for tag

Discuss the JavaScript programing language.

JavaScript Documentation

Posts under JavaScript tag

88 Posts
Sort by:
Post not yet marked as solved
2 Replies
2.3k Views
My iOS app is crashing on the initial load. It's happening both in my Testflight build and also in the production version of the app on the App Store. It was working fine a few days ago; this just started happening all of a sudden. What's strange is that after doing a fresh install, it doesn't happen the first time I open the app. It only happens after I force close the app and open it again (and every time afterward). I'm using Expo and React Native to build the app. I've attached a crash log. crash log - https://developer.apple.com/forums/content/attachment/6a5962a1-56ac-44b0-8ec4-4e8dee0daee8
Posted Last updated
.
Post marked as solved
1 Replies
1.2k Views
The following way of setting the background color of an anchor tag in Safari on iOS 15 isn't working: <html> <head></head> <body><p><a class="content" href="#"><strong><span>Some content with background</span></strong></a> </p> <br /> <button onclick="javascript:onClick();">Click me to change content's background color</button> <script> function onClick(){ var element = document.getElementsByClassName('content')[0]; element.style.backgroundColor = "#888888"; } </script> </body> </html> I had to run the following hack after setting the backgroundColor in order for it to work: // Temporary workaround to redraw the element: var disp = element.style.display; element.style.display = 'none'; var trick = element.offsetHeight; element.style.display = disp; Video demonstration: https://www.dropbox.com/s/2z4kmsypj4ov4sd/iOS%2015%20webkit%20bug.mov?dl=0 Surely this is a bug in Safari unless I might've missed something?
Posted
by karlingen.
Last updated
.
Post not yet marked as solved
0 Replies
321 Views
Hello, I am trying to copy files using AppleScript(javascript) and for the life of me cannot figure out the correct syntax. I have tried all the possible variations i can think of the following but nothing seems to work. Any suggestions would be greatly appreciated!. var app = Application.currentApplication() app.includeStandardAdditions = true // Tried this app.duplicate("/tmp/file1.txt"), {   to: "/tmp/file2.txt" }) // And all sorts of variations such as app.duplicate(Path("/tmp/file1.txt"), {   to: Path("/tmp/file2.txt") }) // And not including file names app.duplicate("/tmp/file1.txt"), {   to: "/tmp/" })
Posted
by pault604.
Last updated
.
Post not yet marked as solved
0 Replies
259 Views
I am on MacOS 12.1 and on safari java script is enabled in the preferences still the sites that require java are not working. On the terminal: ~ % java -version java version "1.8.0_321" Java(TM) SE Runtime Environment (build 1.8.0_321-b07) Java HotSpot(TM) 64-Bit Server VM (build 25.321-b07, mixed mode)
Posted Last updated
.
Post not yet marked as solved
0 Replies
377 Views
Hello, why i cant access to IndexedDB data, created by serviceworker, from DOM? It is different databeses? On all other browsers i can save data in ServiceWorker into IndexedDB and read it in Dom from IndexedDb with same name, But it not work on Mobile Safari, for what it not shared now?
Posted
by vladuser.
Last updated
.
Post not yet marked as solved
0 Replies
402 Views
Target is view html subtitles in vtt format in TV when AirPlay is running from: <video preload="metadata" x-webkit-airplay="allow" src="a.mp4"> <track kind="subtitles" default="" src="en.vtt" srclang="en"> <track kind="subtitles" src="de.vtt" srclang="de"> <track kind="subtitles" src="es.vtt" srclang="es"> <track kind="subtitles" src="fr.vtt" srclang="fr"> </video> The problem is when AirPlay is enabled video and audio plays on TV, but no subtitles showed. I tryied to include vtt/srt subtitles into the mp4 metadata with ffmpeg and subtitles working with VLC but not working when AirPlay this files. ffmpeg -i 8499.mp4 -i 8499.en.vtt -map 0:v -map 0:a -c copy -map 1 -c:s:0 mov_text -metadata:s:s:0 language=en 8499.en.mp4 ffmpeg -i 8499.mp4 -i 8499.en.srt -map 0:v -map 0:a -c copy -map 1 -c:s:0 srt -metadata:s:s:0 language=en 8499.en.mp4 Also tried to send a .m3u8 with no luck. Any of you know how is the basic format for a simple .m3u8 with a .mp4 and .vtt working when AirPlay? Wich is the standard subtitles solution for AirPlay?
Posted
by skatehype.
Last updated
.
Post not yet marked as solved
1 Replies
878 Views
My website shows a video using video tag which worked perfectly until not long ago. The video is working but when pressing on full screen, the video is playing but the screen is black while the sound is still playing. The issue occurs only on iPhones with iOS 15 (using Safari and Chrome also). Things I've tried: I've tried playing the video directly with a URL to the actual file(to check its not codec issue) and it worked properly. My video tag has 'position: absolute;' on it and I tried removing it(even though it breaks my layout) and that didn't work either. Tried pausing the video immediately and playing it after the video loads. Tried applying a background: white; or any non-transparent color to the video tag. Tried removing auto play. Tried to disable 'GPU process: Media' on safari settings just to check if that affects anything and it didnt. This is the html: <video data-test-id="long-video" #longVideo muted controls playsinline [class.d-none]="!isShortVideoHidden" *ngIf="isPageLoaded" src="https://cdn1.someurl.com/videos/commercial_1.mp4" type="video/mp4"> </video> and the css(with the parent): @media only screen and(min-width:992px) { .fixed-video { position: fixed; z-index: 10000; margin: auto; width: 100vw; height: 100vh; left: 0; top: 0; bottom: 0; right: 0; background: rgba(0, 0, 0, 0.5); transition: 0.4s; video { width: 80%; left: 0; right: 0; top: 0; bottom: 0; margin: auto; } } } Please tell me if you have struggled with this and know how to solve it. Thank you :)
Posted Last updated
.
Post not yet marked as solved
0 Replies
274 Views
Hi I'm developing a captive portal with cookies, it works fine in devices like Macs, laptops and android devices but cookies don't work on iPhone. I'm creating cookies in js with document.cookie but the problem is when I connect my iPhone and close CNA, it destroy them and next time I try to connect, cookies don't exist anymore. Someone can help me to figure out how can I avoid CNA destroy my cookies?
Posted Last updated
.
Post marked as solved
5 Replies
3.1k Views
I am trying to run JavaScript only after the page has loaded, and according to here - https://developer.apple.com/documentation/safariservices/safari_app_extensions/injecting_a_script_into_a_webpage, I should use DOMContentLoaded. However, it does not seem to work. This is my content.js file: function runOnStart() {     document.addEventListener('DOMContentLoaded', function(e) {         document.body.style.background = "rgb(20, 20, 20)";         document.html.style.background = "rgb(20, 20, 20)";                var divElements = document.body.getElementsByTagName('div');         for(var i = 0; i < divElements.length; i++) {             let elem = divElements[i];             elem.style.background = "rgba(255, 255, 255, 0.05)";         }     }); } runOnStart(); If I take the code outside of the event listener, it runs fine, but a lot of the elements haven't loaded in yet so it doesn't work as it should. The function is definitely running, but the event listener simply doesn't work. I appreciate any help you can give!
Posted
by JakeShort.
Last updated
.
Post not yet marked as solved
1 Replies
1.6k Views
After I install Java on my Mac I am getting the below error when I try to check the Java version.  % java -version    rosetta error: /var/db/oah/223263137464320_223263137464320/b0347cf8ea34da6748ab1aa2798ae3173ec7284920af0dc3926a4f3708749972/java.aot: attachment of code signature supplement failed: 1 zsh: trace trap  java -version
Posted
by Neeharika.
Last updated
.
Post not yet marked as solved
0 Replies
172 Views
Hi ! I have a problem on Safari browser that I'm not able to solve. On my site I have a form submission with an action. This action takes about 10-15 seconds to finish (because of a big image retouching) so what we want is that when the user makes click on the submit button, a "Loading screen" shows. I've created a div( id=loader ) with a hidden spinner and what we do is that when the user makes clic on the submit button, visibility and opacity of the div is set to 1 and then the form gets submitted. The problem is that the spinner gets frozen and does not animate (on chrome and firefox it works ok). document.getElementById('load').style.visibility='visible';document.getElementById('load').style.display='block';document.getElementById('load').style.opacity='0.98';document.formulario_colores.submit(); ¿Any solution?
Posted
by cargarm3.
Last updated
.
Post not yet marked as solved
1 Replies
313 Views
I'm creating a framework that allows you to easily create html and css web pages in ios style. As long as it's static components that don't have events (e.g. a webpage with a paragraph), that's okay. The problem arises when I have to create a button, recognize and capture the click event. In the same way, however, I have the problem of recognizing and capturing all the other browser events (e.g. the page is loaded into memory). In web development this is handled by javascript. But I would like to replace javascript with my framework and with swift. So how do I interact with browser events? do i have to install swift in the browser? how can I do? thank you
Posted
by Rufy.
Last updated
.
Post not yet marked as solved
2 Replies
1k Views
I have this js code: document.addEventListener('AppleIDSignInOnSuccess', (data) = {     //handle successful response     console.log(data["detail"].authorization.id_token)     response = parseJwt(data["detail"].authorization.id_token)     email = response["email"]     console.log(email)     loginWithEmail(email) //    console.log("APPLE SIGN IN SUCCESSFFUL"); }); //Listen for AppleId authorization failures document.addEventListener('AppleIDSignInOnFailure', (error) = {     //handle error.     alert(JSON.stringify(error))     console.log("APPLE SIGN IN UNSUCCESSFFUL"); }); And it just stopped working. Now every time I sign in I get "APPLE SIGN IN UNSUCCESSFFUL" and the error is {"isTrusted":false}. What are ways around this?
Posted Last updated
.
Post not yet marked as solved
0 Replies
256 Views
I am currently using the WKWebView to evaluate Javascript in my Swift code. This code uses the callAsyncJavaScript to evaluate Javascript. My code takes parameters from the user and then injects those parameters into the Javascript string that is evaluated by callAsyncJavaScript. This of course is an opportunity for js injection attacks that could cause unwanted js to run. I know Apple uses WebViews in their own native apps like Music. But there is nowhere I can find best practices on how to prevent js injection attacks. Anyone have experience with this? Here's a sample function I use. func createMessage(message: ARMessageDto) async -> ArweaveResult {     do {       guard self.walletStr != nil && !self.walletStr!.isEmpty else {         return Result.failure(TransactionError.General("No wallet exists for this user"))       }       let balance = try await self.arweaveQuerySvc.getBalance()       if balance < 1_000_000_000_000 {         return Result.failure(TransactionError.General("Error wallet balance is less than 1,000,000,000,000 Winston"))       }       guard case .none = message.validate() else {         return Result.failure(TransactionError.ParametersInvalid(message.validate()))       }               let respondingToTransId = message.respondingToTransId ?? ""       let result = try await self.webView!.callAsyncJavaScript("""             \(baseScript!)             const arweaveSvc = main('\(walletStr!)');             const result = await arweaveSvc.createMessage(               '\(message.msg)',               \"\(message.userName)\",               \"\(respondingToTransId)\"             );             return result;           """, contentWorld: WKContentWorld.defaultClient)       _ = await self.arweaveQuerySvc.mine()       return try getTransactionResult(result: result)     } catch {       return Result.failure(TransactionError.General("Failed to create profile"))     }   }
Posted
by dharric.
Last updated
.
Post not yet marked as solved
0 Replies
212 Views
Hi! Does anyone have a good solution for the following: I want to use JavaScripts HTMLMediaElement.play() method to play a sound when a button is clicked. Everything working fine in Chrome and Firefox, but Safari 15... Every time I click the button there is some kind of delay or it is not even played. I used the code as described below: const mainButton = document.getElementById('main-button'); const buttonSound = new Audio (button-sound.mp3); mainButton.addEventListener('click', e => { buttonSound.play(); }); It would be great if someone could help!
Posted
by fabdevboy.
Last updated
.
Post not yet marked as solved
0 Replies
351 Views
Hello everyone. I am working on a project (website). And when people visit our website from IOS phones under version 14, clients get an error with localStorage. That is, the system literally does not find localStorage. How to fix this, maybe someone faced a similar problem?
Posted
by Jenya.
Last updated
.
Post marked as solved
2 Replies
459 Views
I want to put on 3D object on websites, but I don’t know how to do. It doesn’t explain AR such as Apple’s product page. It explain like top page’s earth of github.com. In short, I want to put 3D object without page-jumping. This question is maybe not adopted here -apple developer forum-, however I want someone to answer this.
Posted
by A-star.
Last updated
.
Post not yet marked as solved
2 Replies
1.5k Views
I'm currently trying to build my react native app on TestFlight with Fastlane using this tutorial: boorje.com/deploy-react-native-app/ I reached the last step and ran the command bundle exec fastlane beta. This should've built the app on TestFlight, but it didn't. Instead, I received this error: File/Users/myname/Library/Developer/Xcode/DerivedData/GAbeta-etzidujiozhpelfdovtuwdoldqcl/Build/Intermediates.noindex/ArchiveIntermediates/GAbeta/BuildProductsPath/Release-iphoneos/GAbeta.app/main.jsbundle does not exist. Additionally, I was informed that the following build commands failed: PhaseScriptExecution Bundle\ React\ Native\ code\ and\ images /Users/myname/Library/Developer/Xcode/DerivedData/GAbeta-etzidujiozhpelfdovtuwdoldqcl/Build/Intermediates.noindex/ArchiveIntermediates/GAbeta/IntermediateBuildFilesPath/GAbeta.build/Release-iphoneos/GAbeta.build/Script-00DD1BFF1BD5951E006B06BC.sh I've done some research on potential solutions including https://github.com/facebook/react-native/issues/25522#issuecomment-509036251, but none worked. Does anyone have any suggestions in order to solve this issue or could anyone potentially assist in my search?
Posted
by KA1221.
Last updated
.
Post not yet marked as solved
5 Replies
457 Views
Hello! I would like to a deploy a program (more on which later) to the Apple Store, and I have a couple of questions regarding Apple Pay API usage. My product will be a paid program, and I have some problems with the Apple Pay API due to technical reasons. My program is an "Electron-like" application, it consists of two parts, backend, and UI. The "Backend" runs directly in the user's computer, it's written in Python and Flask. The "UI" is actually a browser that opens a webpage from the "Backend", and interacts with it using AJAX. The issue here is that I don't understand how in-app payments can be implemented. As far as I understand, the only option to deploy a paid application and the Apple Store is to use Apple Pay API, which is only available from Swift or Objective-C. I don't understand how can I use Apple Pay API, how I can check for a valid payment, etc. Can you please send me some kind of guide, tutorial, or instruction that can help me to use Apple Pay in my program? Thank you very much, Alex.
Posted
by abtco.
Last updated
.
Post not yet marked as solved
0 Replies
397 Views
This HTML and javascript content Make my WKWebView crash in ios15 What is wrong with this part? Attach my crash log Please help..... Swipy  2021-11-23, 3-27 PM.crash 2021-11-24 09:48:26.705150+0800 Swipy[510:18443] -[__NSDictionaryM length]: unrecognized selector sent to instance 0x281eb9560 2021-11-24 09:48:26.715730+0800 Swipy[510:18443] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDictionaryM length]: unrecognized selector sent to instance 0x281eb9560' *** First throw call stack: (0x181be904c 0x19a25df54 0x181cc6014 0x181b7e474 0x181b7d5b0 0x18dc24718 0x19061d2a4 0x1907ec908 0x1907ec470 0x19074e16c 0x19075b464 0x190ae205c 0x1903278e0 0x190329060 0x18dc1e074 0x18dc1f1e4 0x181c0b020 0x181c1bce0 0x181b55fe8 0x181b5b7f4 0x181b6f3b8 0x19d4ff38c 0x18450f6a8 0x18428e7f4 0x100d60108 0x101481a24) libc++abi: terminating with uncaught exception of type NSException dyld4 config: DYLD_LIBRARY_PATH=/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/Developer/usr/lib/libBacktraceRecording.dylib:/Developer/usr/lib/libMainThreadChecker.dylib:/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDictionaryM length]: unrecognized selector sent to instance 0x281eb9560' terminating with uncaught exception of type NSException
Posted Last updated
.