অন্লিক ওপেন উইন্ডো এবং নির্দিষ্ট আকার


90

আমার এই জাতীয় লিঙ্ক আছে:

<a href="/index2.php?option=com_jumi&amp;fileid=3&amp;Itemid=11" onclick="window.open(this.href,'targetWindow','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,')

আমি নতুন খোলার উইন্ডোটি একটি নির্দিষ্ট আকারে খুলতে চাই। আমি উচ্চতা এবং প্রস্থ কীভাবে নির্দিষ্ট করব?

উত্তর:


182
<a href="/index2.php?option=com_jumi&amp;fileid=3&amp;Itemid=11"
   onclick="window.open(this.href,'targetWindow',
                                   `toolbar=no,
                                    location=no,
                                    status=no,
                                    menubar=no,
                                    scrollbars=yes,
                                    resizable=yes,
                                    width=SomeSize,
                                    height=SomeSize`);
 return false;">Popup link</a>

যেখানে প্রস্থ এবং উচ্চতা একক ছাড়াই পিক্সেল (প্রস্থ = 400 প্রস্থ নয় = 400px)।

বেশিরভাগ ব্রাউজারে এটি লাইন ব্রেক ব্যতিরেকে না লিখলে কাজ করবে না, একবার ভেরিয়েবলগুলি সেটআপ হয়ে গেলে এক লাইনে সমস্ত কিছু থাকে:

<a href="/index2.php?option=com_jumi&amp;fileid=3&amp;Itemid=11" onclick="window.open(this.href,'targetWindow','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=SomeSize,height=SomeSize'); return false;">Popup link</a> 

14
আপনি সর্বশেষ ")" এর জন্য "অক্ষরটিও বদল করতে চান); মিথ্যা ফিরুন;" পপআপ ছাড়াও মূল লিঙ্কটি খোলার প্রতিরোধ করতে।
অ্যান্ড্রু

4
একটি পুরানো এক কিন্তু আমি এই @AndrewSpear থেকে উত্তর দিন অনুযায়ী অনুসন্ধান তাই সংশোধিত উত্তর মাধ্যমে পাওয়া
নিল

4
@ ল্যারি হিপ আমি কীভাবে এটিকে পর্দার আকারের জন্য ফিট করতে পারি?
ইধাম চৌধুরী ry

@ ইডামচৌড্রি কেবল প্রস্থ / উচ্চতার বৈশিষ্ট্যগুলি সরিয়ে ফেলুন এবং এটি স্বয়ংক্রিয়ভাবে সমস্ত উপলব্ধ স্থান গ্রহণ করবে। আমি বিশ্বাস করি সেটিংসও width=100vw, height=100vhকাজ করবে।
ভাদোরকোয়েস্ট

4
আমার জন্য এটি কাজ করে তবে একটি গুরুত্বপূর্ণ বিষয় - উপরের উদাহরণের মতো আপনার ফাংশনের শরীরে লাইন ব্রেকগুলি ব্যবহার করা উচিত নয়। আমি লাইন ব্রেকগুলি সরিয়েছি এবং এটি আমার পক্ষে কাজ করে।
ইউজিন



12

প্যারামিটার স্ট্রিং এ কেবল তাদের যুক্ত করুন।

window.open(this.href,'targetWindow','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=350,height=250')

11
<a style="cursor:pointer"
  onclick=" window.open('http://YOUR.URL.TARGET','',' scrollbars=yes,menubar=no,width=500, resizable=yes,toolbar=no,location=no,status=no')">Your text</a>

যদিও আমি জিজ্ঞাসা করি, এটি ইতিমধ্যে প্রদত্ত সমস্ত উত্তরগুলিতে কী যুক্ত করে?
EWit

3

এগুলি মজিলা বিকাশকারী নেটওয়ার্কের উইন্ডো.পেন পৃষ্ঠা থেকে সেরা অনুশীলনগুলি :

<script type="text/javascript">
var windowObjectReference = null; // global variable

function openFFPromotionPopup() {
  if(windowObjectReference == null || windowObjectReference.closed)
  /* if the pointer to the window object in memory does not exist
     or if such pointer exists but the window was closed */

  {
    windowObjectReference = window.open("http://www.spreadfirefox.com/",
   "PromoteFirefoxWindowName", "resizable,scrollbars,status");
    /* then create it. The new window will be created and
       will be brought on top of any other window. */
  }
  else
  {
    windowObjectReference.focus();
    /* else the window reference must exist and the window
       is not closed; therefore, we can bring it back on top of any other
       window with the focus() method. There would be no need to re-create
       the window or to reload the referenced resource. */
  };
}
</script>

<p><a
 href="http://www.spreadfirefox.com/"
 target="PromoteFirefoxWindowName"
 onclick="openFFPromotionPopup(); return false;" 
 title="This link will create a new window or will re-use an already opened one"
>Promote Firefox adoption</a></p>

0

যে কেউ দ্রুত Vue ফাইল উপাদান খুঁজছেন, আপনি এখানে যান:

// WindowUrl.vue

<template>
    <a :href="url" :class="classes" @click="open">
        <slot></slot>
    </a>
</template>

<script>
    export default {
        props: {
            url: String,
            width: String,
            height: String,
            classes: String,
        },
        methods: {
            open(e) {
                // Prevent the link from opening on the parent page.
                e.preventDefault();

                window.open(
                    this.url,
                    'targetWindow',
                    `toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=${this.width},height=${this.height}`
                );
            }
        }
    }
</script>

ব্যবহার:

<window-url url="/print/shipping" class="btn btn-primary" height="250" width="250">
    Print Shipping Label
</window-url>

0

টাইপস্ক্রিপ্ট মধ্যে ফাংশন ব্যবহার

openWindow(){
    //you may choose to deduct some value from current screen size
    let height = window.screen.availHeight-100;
    let width = window.screen.availWidth-150;
    window.open("http://your_url",`width=${width},height=${height}`);
}
আমাদের সাইট ব্যবহার করে, আপনি স্বীকার করেছেন যে আপনি আমাদের কুকি নীতি এবং গোপনীয়তা নীতিটি পড়েছেন এবং বুঝতে পেরেছেন ।
Licensed under cc by-sa 3.0 with attribution required.