1

I insert a page containing the following content

<a href="data:text/html;base64,PGlmcmFtZSBzcmM9ImphdmFzY3JpcHQ6ZG9jdW1lbnQuZG9tYWluKSI+PC9pZnJhbWU+">test</a>

But when i click on the link it shows me an empty alert box. Why is document.domain not working?

The alert box should contain my domain but it's empty, do you know what is that due to?

  • Welcome to Stackoverflow. `document.domain` is not in the code you posted. We have no way of knowing what is wrong without more code. –  Feb 26 '19 at 18:32
  • That url decodes to ``. What is that supposed to mean? – Scott Sauyet Feb 26 '19 at 18:37
  • @ScottSauyet, I'm trying to understand why the alert box is empty instead of containing my document.domain value – Jyosk Natalm Feb 26 '19 at 18:53
  • @Chipster, it's base64 encoded... – Jyosk Natalm Feb 26 '19 at 18:53
  • Maybe it's missing the `(`? Or it doesn't need the `)`? –  Feb 26 '19 at 18:55
  • There is no `alert` statement in there, just `javascript:document.domain`. – Scott Sauyet Feb 26 '19 at 19:03
  • @Chipster, yeah it needs the (), i adjusted it to and base64 encoded it - It still show an empty alert box thou.... – Jyosk Natalm Feb 26 '19 at 19:03
  • @ScottSauyet Maybe he doesn't mean alert alert, but possibly the iframe by "alert". –  Feb 26 '19 at 19:05
  • @JyoskNatalm Perhaps could you post some relevant code for `document.domain()`? –  Feb 26 '19 at 19:06
  • If i used or it works perfectly but with document.domain and document.cookie the alert box is empty. – Jyosk Natalm Feb 26 '19 at 19:07
  • If you try ````, it might show whether your domain is an empty string. – Scott Sauyet Feb 26 '19 at 19:11
  • @ScottSauyet I'm passing this data value as post request redirect and it shows an empty string instead of previous domain. – Jyosk Natalm Feb 26 '19 at 19:31
  • Perhaps I'm confused, but I don't see how you're expecting any sort of document.domain when your source is a `data:` url. Are you expecting it to share the domain of the document containing that anchor (``) element? – Scott Sauyet Feb 26 '19 at 19:45
  • @ScottSauyet, I don't know if still possible, but i'm expecting that after clicking the link containing my data: url the alert box show my current document domain. I have uploaded the html page in my domain but the alert box is empty. – Jyosk Natalm Feb 26 '19 at 20:15
  • A `data:` uri is stand-alone. It shouldn't, as I understand it, ever have a domain. – Scott Sauyet Feb 27 '19 at 13:36

0 Answers0