javascript - Redirect the page to back if URL changed -


मेरा होमपेज यूआरएल // localhost: 8090 है, यह index.html < / Strong> के साथ main.js

यदि यूआरएल को // localhost: 8090 / icons / sample.png में बदल दिया गया है। मुझे // localhost: 8090 के रूप में उपयोगकर्ता को पिछले पृष्ठ पर रीडायरेक्ट करना होगा।

मैंने कोशिश की:

main.js

  यदि (window.location.href.indexOf ("आइकॉन्स") & gt; -1) {window.history.back ()); }   

यह काम नहीं करता है। पेज केवल छवि प्रदर्शित करता है

आधुनिक ब्राउज़रों में (IE8 +, एफएफ 3.6 +, क्रोम), आप बस हैश बदलते सुन सकते हैं विंडो पर ईवेंट।

  $ (window) .bind ('hashchange', फ़ंक्शन () {window.history.back ()} / * बातें * /});   

कुछ पुराने ब्राउज़रों में, आपको एक टाइमर की आवश्यकता होती है जो लगातार location.hash जांचती है। यदि आप jQuery का उपयोग कर रहे हैं, तो ऐसा एक ऐसा प्लगिन है जो वास्तव में करता है।

  फ़ंक्शन हैशहैंडलर () {this.oldHash = window.location.hash; this.Check; Var = यह; Var पता = समारोह () (यदि (that.oldHash! = Window.location.hash) {window.history.back ()); }}; This.Check = setInterval (function () {detect ()}, 100); } Var hashDetection = नया हैशहैंडलर ();   

क्या आप हैश परिवर्तन ईवेंट पर काम करते हैं।

Comments

Popular posts from this blog

Delphi: missing interface declarations for UI Automation methods -

php - how to change mysql_result($res, 0, "url"); to mysqli -

android - How to attach an image from an app to gmail -