1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Save a page instead of openning it

Discussion in 'JavaScript' started by rochdi70, Jun 20, 2023.

  1. #1
    Hi Guys,

    We normally use window.open to open a page or a popup window (window.open(URTL), is there a way intead makint call to open we make it to save to a file path (eg.c:\temp) using that page url instead of opening it to the screen?




    Thanks
     
    Last edited: Jun 20, 2023
    rochdi70, Jun 20, 2023 IP
  2. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #2
    Generally speaking with window.open being a scripting only solution that's kinda shite from an accessibility standpoint.

    If you had an anchor you could just add the "download" attribute.

    <a href="/downloads/whatever.txt" download>Download FIle</a>
    Code (markup):
    If it's something you'd be accessing from JS only (boo, hiss) you could always do the old body append, click, and remove trick.

    
    let anchor = document.body.appendChild(
    	Object.assign(
    		document.createElement("a"),
    		{
    			download : "someOtherName.txt",
    			href : "/downloads/something.txt"
    		}
    	)
    );
    anchor.click();
    anchor.remove();
    
    Code (markup):
    Forget not the download attribute can let you name the download if you want it to be something different from the name on the server.

    https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attributes

    Also if it's something you're generating in your client side scripting, you can encode it into the href:

    
    	href : "data:text/plain;charset=utf-8," + encodeURIComponent(content),
    
    Code (markup):
    Where "content' is your text. You can also do other mime-types if you have URI safe encoding.
     
    deathshadow, Jun 22, 2023 IP
  3. phoenixtropicals

    phoenixtropicals Active Member

    Messages:
    138
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    50
    #3
    I prefer to use html for popups rather than launching another browser. Example code.

    css:
    
    .BDT_Dialog_Layer {
        position: absolute;
        display: table;
        top: 0px;
        left: 0px;
        height: 99%;
        width: 99%;
    }
    .BDT_Dialog_Center {
        position:fixed;
        top:5%;
        width:100%;
    }
    .BDT_Dialog_Decoration {
        position:relative;
        margin:0 auto;
        text-align: center;
        background-color: #ffffff;
        display: table;   
    /* --    background-color: #DDDDDD;
        filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#FFFFFF', endColorstr='#BBBBBB');
        background-image: -webkit-gradient(  linear,  left top,  left bottom,  color-stop(0.1, #FFFFFF),  color-stop(1, #BBBBBB)  );
        background-image: -moz-linear-gradient(  center top,  #FFFFFF 10%,  #BBBBBB 100%  ); -- */
        -moz-border-radius: 15px;
        -webkit-border-radius: 15px;
        -khtml-border-radius: 15px;
        border-radius: 15px;
        -moz-box-shadow: 0 1px 8px #666666, 0 1px 4px #000000;
        -webkit-box-shadow: 0 1px 8px #666666, 0 1px 4px #000000;
        -khtml-box-shadow: 0 1px 8px #666666, 0 1px 4px #000000;
        box-shadow: 0 1px 8px #666666, 0 1px 4px #000000;   
    }
    
    Code (markup):
    html:

    
    <div id="dialogLayer" class="BDT_Dialog_Layer">
            <div class="BDT_Dialog_Center">
                <div class="BDT_Dialog_Decoration">      
                    your stuff here.
                </div>
            </div>
        </div>
    
    Code (markup):
     
    Last edited: Aug 15, 2023
    phoenixtropicals, Aug 15, 2023 IP
  4. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #4
    Which has WHAT to do with their question exactly?

    Though that code is such broken inaccessible shite, I bet that's another of these new "premium members" that's just an AI bot. DIV soup, endless classes for nothing, display:table doing flex's job, and PX metrics? /FAIL/ hard.
     
    deathshadow, Aug 22, 2023 IP