Mozilla 도움말 검색

고객 지원 사기를 피하세요. 저희는 여러분께 절대로 전화를 걸거나 문자를 보내거나 개인 정보를 공유하도록 요청하지 않습니다. "악용 사례 신고"옵션을 사용하여 의심스러운 활동을 신고해 주세요.

자세히 살펴보기

Modify URL in address bar with Javascript

  • 4 답장
  • 3 이 문제를 만남
  • 2 보기
  • 최종 답변자: AAronoff

more options

I was using a bookmarklet in Firefox that modified the URL in the address bar to switch the page view in Gmail from text to HTML after "Show original" was selected for a particular message:

javascript:window.location=window.location.href.replace("view=om&th","view=lg&msg");

This bookmarklet no longer works.

Is there any way to allow Javascript to access the URL in the address bar?

TIA and regards, Andy

I was using a bookmarklet in Firefox that modified the URL in the address bar to switch the page view in Gmail from text to HTML after "Show original" was selected for a particular message: javascript:window.location=window.location.href.replace("view=om&th","view=lg&msg"); This bookmarklet no longer works. Is there any way to allow Javascript to access the URL in the address bar? TIA and regards, Andy

모든 댓글 (4)

more options

If I look at Gmail then I see the &v parameter, so maybe try that. Maybe also try not to depend on the order of parameters and split them over more replace calls. I don't know about the 'lg' value (view=lg) as I'm not seeing it in the page source.

  • javascript:void(location.href=location.href.replace("&v=om","&v=c").replace("",""));
more options

FOA, thanks for your reply.

I don't think my problem has been understood.

The Javascript in my first message is correctly constructed. It worked for well over a year in Firefox and it works correctly in IE 11. The problem is not the Javascript. It's Firefox, which appears to have been hardened to refuse access to the URL in the address bar by Javascript in a bookmarklet. (I also tried it in Safe Mode, with no success.)

Are you able to modify the URL in the address bar via Javascript from a Firefox 55.0.3 (Windows 32-bit) bookmarklet? If not, Is there any way to allow this access via about:config?

regards, Andy

more options

OK, that looks like a CSP issue where the website only allows to run scripts from their own website (self).

Unfortunately Firefox applies CSP rules to bookmarklets and thus you can't run these.

You can run the JavaScript code in the Web Console as a workaround.

I don't know whether NoScript can bypass CSP restrictions for bookmarklets.

more options

> that looks like a CSP issue

I'm no longer sure what the issue is.

I uninstalled Firefox and installed previous versions. That had no effect.

I created a brand new profile. That had no effect, either.

A bookmarklet worked for a long time and then suddenly stopped working. (It continues to work in IE 11.)

I checked the bookmarklet in Firefox 55.0.3 on another Windows 7 PC. It didn't work there, either.

I don't understand why this bookmarklet stopped working in Firefox.

Thanks for trying to help.