الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

المساعدة في جعل الكود يفتح أكثر من موقع

بدأه مبتدئ بالجافا في 1 فبراير 2013 · 6 رد · 1,432 مشاهدة · في قسم البرمجة بــ Javascript
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

مساء الخير عليكم جميعاً 
 
أنا لدي كود جافا لفتح موقع عند الضغط على الصفحة بالكوكيز 
 
ولكن أريد جعل الكود يفتح أكثر من موقع بعنى أن الزائر الأول يفتح له 
موقع عشوائي من المحددة والزائر الثاني يفتح له موقع عشوائي من المحددة

 

<script language="JavaScript1.1">
var popunder
function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { // if cookie exists
offset += search.length
// set index of beginning of value
end = document.cookie.indexOf(";", offset);
// set index of end of cookie value
if (end == -1)
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}
popfrequency="15 minutes"
function resetcookie(){
var expireDate = new Date()
expireDate.setMinutes(expireDate.getMinutes()-0)
document.cookie = "popunder=;path=/;expires=" + expireDate.toGMTString()
}
function loadornot(){
if (get_cookie('popunder')==''){
loadpopunder()
var expireDate = new Date()
expireDate.setMinutes(expireDate.getMinutes()+parseInt(popfrequency))
document.cookie = "popunder="+parseInt(popfrequency)+";path=/;expires=" + expireDate.toGMTString()
}
}
function loadpopunder(){
document.write('<body onclick="rwmrgfdq_Popup()" >');
}
if (get_cookie('popunder')!=parseInt(popfrequency))
resetcookie()
loadornot()

</script>  
<script type="text/javascript"> <!--
var opened;
function rwmrgfdq_Popup()
{
if(opened != 1)
{
opened = 1;
window.open("http://www.google.com/", "rwmrgfdqpop", "scrollbars = 1, resizable = 1,status = 1");
}
}
//--> </script>

 

أتمنى أن أجد الحل لديكم في أسرع وقت ممكن 

تم تعديل هذه المشاركة بواسطة مبتدئ بالجافا في 1 فبراير 2013 في 19:37

#2

اخي هذا منتدى Java وليس منتدى Javascript ، انقل موضوعك الى قسم منتديات الــ Web

No intellectual battle was ever won through retreat
You do not watch Gintama? Dude, you are missing a lot!


صورةmsrgb1485.gif ocajavase7programmerclr.gif

#3

تم نقل الموضوع.

Do as I say, not as I do

We are Anonymous. We are Legion. We don't forgive. We don't forget

#4

ليس هناك أحد لديه حل لهذا الموضوع 

#5

هذا مثال لفتح كود من قائمة عشوائياً:

<!DOCTYPE html><head>  <meta charset="utf-8">  <title>مثال</title>  <script>  function open_random_website() {    var websites_list = [        'http://www.google.com.sa',        '',        'http://www.mozilla.org'        ];    var index = (Math.floor(Math.random() * 10) % (websites_list.length));    document.location = websites_list[index];  }  </script></head><body>    <button onclick="open_random_website()">جرب هنا</button></body></html>
#6

شكراً أخي العزيز على الكود 

 

ولكن هذا الكود لابد من الضغط على الزر حتى تفتح الصفحة 

 

أنا أريد عندما يتم الضغط على أي مكان في الصفحة يتم فتح روابط عشوائي في نافذة جديدة 

مثل الكود إلى في بداية الموضوع 

#7
<!DOCTYPE html><head>  <meta charset="utf-8">  <title>مثال</title>  <script>  function open_random_website() {    var websites_list = [        'http://www.google.com.sa',        '',        'http://www.mozilla.org'        ];    var index = (Math.floor(Math.random() * 10) % (websites_list.length));    document.location = websites_list[index];  }   document.addEventListener('click', open_random_website, false);  </script></head><body>    <p>إضغط في أيّ مكان</p></body></html>

مواضيع مشابهة