--- title: ServiceWorker.scriptURL slug: Web/API/ServiceWorker/scriptURL translation_of: Web/API/ServiceWorker/scriptURL ---
{{SeeCompatTable}}{{APIRef("Service Workers API")}}

作为ServiceWorkerRegistration的一部分定义,会返回该ServiceWorker的序列化脚本url. 必须与document注册ServiceWorker的地址同源.

语法

someURL = ServiceWorker.scriptURL

一个 {{domxref("USVString")}} (另见 WebIDL definition of USVString.)

规范

规范 状态 附注
{{SpecName('Service Workers', '#service-worker-url-attribute', 'scriptURL')}} {{Spec2('Service Workers')}} Initial definition

浏览器兼容性

{{CompatibilityTable}}
Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support {{CompatChrome(40.0)}} {{ CompatGeckoDesktop("44.0") }}[1] {{CompatNo}} 24 {{CompatNo}}
Feature Android Android Webview Firefox Mobile (Gecko) Firefox OS IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support {{CompatNo}} {{CompatNo}} {{ CompatGeckoMobile("44.0") }} {{ CompatVersionUnknown }} {{CompatNo}} {{CompatUnknown}} {{CompatNo}} {{CompatChrome(40.0)}}

[1] Service workers (and Push) have been disabled in the Firefox 45 and 52 Extended Support Releases (ESR.)