Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6661695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:18:39+00:00 2026-05-26T02:18:39+00:00

This is what I am trying to accomplish: location.replace(‘http://localhost:8888/test/index.php?site=’ + document.URL); So I need

  • 0

This is what I am trying to accomplish:

location.replace('http://localhost:8888/test/index.php?site=' + document.URL);

So I need the current URL to be send as a string of the site variable. Though the document.URL is not working, is there a way to get that working?

The idea is when I go to index.php the ‘site’ is inserted into a database. I would like the above link to work as a bookmarklet, (second part of the question) is there a way to execute that code but to still remain in the same page?

Basically if I am at google.com and click on the bookmarklet to execute the code above, Is there a way to remain at google.com but for the ..index.php to run in the background

At the moment I really need help with the first part of the question – but maybe you have any tips on how to achieve the second part?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:18:40+00:00Added an answer on May 26, 2026 at 2:18 am
    • Use encodeURIComponent(location.href), instead of document.URL
      *

      1. You could create an IFRame, and set the src property of it.
      2. Another option is to execute a XMLHttpRequest [1]
      3. (new Image).src = url
      4. window.open(url) (may be blocked, hinders the user)
      5. Create a form, and submit it (using target=__, where __ can be _blank or a frame name.

    [1] This method does not work across different domains. See also: MDN: Using XMLHttpRequest.

    Another method (allows passing feedback from the server, in the form of JavaScript code).

    javascript:void(function(){
        var s = document.createElement("script");
        s.src = "http://localhost:8888/test/index.php?site="
                  + encodeURIComponent(location.href);
        document.body.appendChild(s);
    })();
    

    Using Image:

    javascript:void(function(){
        (new Image()).src = "http://localhost:8888/test/index.php?site=" +
             encodeURIComponent(location.href);
    })();
    

    EDIT alert + auto close

    As requested in the comments, a pure JS alert which automatically closes after a certain time has elapsed. I’ve kept the function simple, for educative purposes. If you’re lazy, JQuery is also an option, although it’s overkill to include a whole framework for automatically hiding an “alert” box

    /* @name        alertFade
       @description Shows a message, closing automatically after # milliseconds
       @param String message      Message to display
       @param number autoclose_ms Time in milliseconds till the message has to be closed
       @param number softFade_ms  Time in milliseconds for the fade animation*/
    function alertFade(message, autoclose_ms, softFade_ms){
        if(typeof message == "undefined") message = "";
        if(isNaN(autoclose_ms)) autoclose_ms = 3000;
        if(isNaN(softFade_ms)) softFade_ms = 1000;
        var container = document.createElement("div"),
            alertBox = document.createElement("div"),
            alertContent = document.createElement("div"),
            dismiss = document.createElement("div");
        container.style.cssText = "position:fixed;top:0;left:0;width:100%;height:100%;display:table;opacity:1;background:transparent;";
        alertBox.style.cssText = "display:table-cell;vertical-align:middle;text-align:center;";
        alertContent.style.cssText = "display:inline-block;white-space:pre-wrap;word-wrap:break-word;background:#DDF;font-size:normal;padding:5px";
        dismiss.style.cssText = "font-size:small;border-bottom:1px solid #CCC";
    
        dismiss.appendChild(document.createTextNode("(Click to dismiss)"));
        dismiss.onclick = fadeClose;
        alertContent.appendChild(dismiss);
        alertContent.appendChild(document.createTextNode(message));
        alertBox.appendChild(alertContent);
        container.appendChild(alertBox);
        document.body.appendChild(container);
        var alertAutoClose = window.setTimeout(fadeClose, autoclose_ms);
        var fadeTimer;
    
        function closeAlert(){
            window.clearTimeout(alertAutoClose);
            window.clearInterval(fadeTimer);
            if(container.parentNode) container.parentNode.removeChild(container);
        }
        function fadeClose(){
            if(!softFade_ms) return closeAlert(); //No fade = close immediately
    
            var opacity = 1;
            fadeTimer = window.setInterval(function(){
                opacity -= .1; //Reduce the opacity by 10% per interval
                if(opacity <= 0) return closeAlert();
                container.style.opacity = opacity;
            }, softFade_ms/10);
        }
    }
    //Example:
    alertFade("Message!");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to accomplish what's being demonstrated at this site for an experiment I'm
I'm trying to accomplish this: strcat('red ', 'yellow ', 'white ') I expected to
So I am trying to accomplish something like this: SELECT * FROM table WHERE
I'm trying to accomplish the following using CSS: <table border=1 width=300px> <tr> <td rowspan=2>This
I could probably write this myself, but the specific way I'm trying to accomplish
I'm trying to determine if there is a way to accomplish this elegantly. I
I am stuck with using Dojo to accomplish this. Basically what I am trying
I am trying this in my Form Load Event cmdCancel.Attributes.Add(onClick, document.forms[0].reset();return false;) but it
I'm trying to use an offline MBTiles database using Route-Me . To accomplish this,
So, this is a fairly simple thing I'm trying to accomplish (javascript), but it's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.