עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

בעייה מוזרה בסקריפט - Javascript

Featured Replies

פורסם

הסקריפט (אני חושב שיש דרך יותר פשוטה לעשות את זה אבל חשבתי עליה אחרי שסיימתי את רוב הקוד, אז נא לא להגיד לי לעשות את זה אחרת):

function removeA()
{
var aArray = document.getElementsByTagName("a");
var i=0;
for (i=0; i<aArray.length;i++)
{
if (aArray[i].className == "fmllink")
{
if (aArray[i].parentNode.tagName=="P")
{

var aArrInP = aArray[i].parentNode.getElementsByTagName("a");
var j=0;
var tmpStr=""
for (j=0;j<aArrInP.length;j++)
{
tmpStr += aArrInP[j].innerHTML;
aArray[i].parentNode.removeChild(aArrInP[j]);
}

aArray[i].parentNode.innerHTML = tmpStr;
}
}
}

}

הבעייה עם הסקריפט שהוא מעיף רק את תגי הa האי-זוגיים (ראשון, שלישי, חמישי...) ואני לא מבין למה

<a href="/miscellaneous/2237527" class="fmllink">Today, I drove 150 miles to see one of my favorite singers in concert.</a><a href="/miscellaneous/2237527" class="fmllink"> Before I got out of the car I checked to make sure I had the tickets.</a><a href="/miscellaneous/2237527" class="fmllink"> Did I have the tickets? Yes.</a><a href="/miscellaneous/2237527" class="fmllink"> Were they for today's concert? Nope.</a><a href="/miscellaneous/2237527" class="fmllink"> FML</a>

זה קןד לדוגמה (לפני השינוי כמובן)

פורסם

פה הבעיה שלך...

אתה מוריד בכל לופ אחד מהאובייקטים במערך...

ואז ה- aArrInP.length כל פעם פוחת ו-J נשאר קבוע ולא יחסי לירידה בערך של aArrInP.length

				for (j=0;j<aArrInP.length;j++)

					aArray[i].parentNode.removeChild(aArrInP[j]);

הפיתרון:

תעשה 2 לולאות אחת שמעבירה את כל ה-innerHTML ל-tmp שלך

ואז עוד אחת שמורידה את אובייקטים מהמערך

פורסם
  • מחבר

וואלה, צודק, תודה...

מה שמעצבן זה שהדבר הזה מתעדכן כל הזמן... זה לא הפעם הראשונה שזה עושה לי צרות

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.