I am a multimedia Production Specialist whom has been thrown into the deep end at work. We produce coursware btw.

I have to find a way to create a "Bookmark Button", but, the pages are NOT online, they run directly from a pc. HOW do I do this?

The only scripting I can find works with actual web sites, as in, has to have "http://". As soon as I change the "path" it refuses to work and gives me errors.

Dani AI

Generated

Short, practical path forward (for ; following up on ’s note about local files):

For distributable courseware (CD/DVD or mixed server/USB/PC installs) avoid trying to force a browser to create an OS-level bookmark — drive letters and browser policies make that brittle. A much more reliable pattern is an in-app bookmark list that saves a small, portable reference (a relative path or a URL fragment/hash) and rebuilds links at runtime against the current document base. See how relative references resolve against a base URL and how fragments (hashes) carry state in a page. (developer.mozilla.org)

Minimal implementation idea (single-root page or hash-based navigation works best): provide a “Save bookmark” button that stores a small object like { title, fragmentOrRelativePath } in browser storage, and render a local “Bookmarks” panel that links to those stored entries. Example (very small) — add, render, export/import:

function addBookmark(){
  const key = 'course-bookmarks';
  const list = JSON.parse(localStorage.getItem(key) || '[]');
  list.push({title: document.title, hash: location.hash || '#'});
  localStorage.setItem(key, JSON.stringify(list));
  renderBookmarks();
}

function renderBookmarks(){
  const list = JSON.parse(localStorage.getItem('course-bookmarks') || '[]');
  document.getElementById('bookmarks').innerHTML =
    list.map(b=>`<li><a href="${b.hash}">${b.title}</a></li>`).join('');
}

function exportBookmarks(){
  const blob = new Blob([localStorage.getItem('course-bookmarks') || '[]'], {type:'application/json'});
  const a = document.createElement('a'); a.href = URL.createObjectURL(blob); a.download='bookmarks.json'; a.click();
}

Test and provide a fallback: localStorage behavior for file: pages is inconsistent across browsers, so include the simple export/import step above and a “How to bookmark manually (Ctrl+D / star icon)” help page for clients. (developer.mozilla.org)

Why not use AddFavorite/sidebar calls? Those are browser-specific, deprecated, and may refuse file:// URLs; programmatic creation of real browser bookmarks across unknown client machines is only practical via a browser extension (bookmarks API) — which requires users to install it. For most offline courseware the internal/bookmark-manager + export approach is the most robust. (learn.microsoft.com)

Recommended Answers

All 4 Replies

Local links would start with something like "file:///c:/" or another letter if it's not your "c" drive.

ok, change of plans. What if it is being written to a DVD? (instead of C Drive)

What is the drive letter of your DVD? Use that letter in place of the "c" above.

What is the drive letter of your DVD? Use that letter in place of the "c" above.

That will not work as the DVD is for clients. It is not allowed (for me) to ask what they call their drives, it is not professional. Also, their drives could also be named differently as it is coursware for multiple students. It could run off a server, or directly off their PC's.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.