
Новичок
Профиль
Группа: Участник
Сообщений: 3
Регистрация: 15.3.2010
Репутация: нет Всего: нет
|
Всем привет! Помогите пожайлуста справится с проблемой, если это возможно. Сама я яваскрипт не знаю вообще, только html. Для страниц нахожу готовые скрипты в инете. Сейчас делаю дипломную работу - электронный справочник, нашла красивое меню, но несколько проблем. Во-первых, оно не переносит слова на размер фрейма, и во-вторых, ссылки на странице открываются в этот же фрейме, а мне надо чтобы они открывались в другом. Возможно ли это исправить?? Подскажите, если не трудно... | Код | <HTML> <HEAD> <TITLE>Проводник</TITLE> <script LANGUAGE="JavaScript"> <!--
// Copyright (c) 1996-1997 Tomer Shiran. All rights reserved. // Permission given to use the script provided that this notice remains as is. // Additional scripts can be found at http://www.geocities.com/~yehuda/
// Boolean variable specified if alert should be displayed if cookie exceeds 4KB var caution = false
// name - name of the cookie // value - value of the cookie // [expires] - expiration date of the cookie (defaults to end of current session) // [path] - path for which the cookie is valid (defaults to path of calling document) // [domain] - domain for which the cookie is valid (defaults to domain of calling document) // [secure] - Boolean value indicating if the cookie transmission requires a secure transmission // * an argument defaults when it is assigned null as a placeholder // * a null placeholder is not required for trailing omitted arguments function setCookie(name, value, expires, path, domain, secure) { var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "") if (!caution || (name + "=" + escape(value)).length <= 4000) document.cookie = curCookie else if (confirm("Cookie exceeds 4KB and will be cut!")) document.cookie = curCookie }
// name - name of the desired cookie // * return string containing value of specified cookie or null if cookie does not exist function getCookie(name) { var prefix = name + "=" var cookieStartIndex = document.cookie.indexOf(prefix) if (cookieStartIndex == -1) return null var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length) if (cookieEndIndex == -1) cookieEndIndex = document.cookie.length return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex)) }
// name - name of the cookie // [path] - path of the cookie (must be same as path used to create cookie) // [domain] - domain of the cookie (must be same as domain used to create cookie) // * path and domain default if assigned null or omitted if no explicit argument proceeds function deleteCookie(name, path, domain) { if (getCookie(name)) { document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT" } }
// date - any instance of the Date object // * you should hand all instances of the Date object to this function for "repairs" // * this function is taken from Chapter 14, "Time and Date in JavaScript", in "Learn Advanced JavaScript Programming" function fixDate(date) { var base = new Date(0) var skew = base.getTime() if (skew > 0) date.setTime(date.getTime() - skew) }
// constructor function to create an entry (parent or child) function item(parent, text, depth) { this.parent = parent // is this item a parent? this.text = text // text for link (may include HTML) this.depth = depth // nested depth }
// constructor function to create array (compatible with all browsers) function makeArray(length) { this.length = length // length of array (integer) }
// create items of outline function makeDatabase() { outline = new makeArray(27) // create global object
// create items in outline outline[0] = new item(true, '1. Выпускная квалификационная работа', 0) outline[1] = new item(false, '<A HREF="page/11.html">1.1 Общие положения</A>', 1) outline[2] = new item(true, '1.2 Тематика выпускных квалификационных работ', 1) outline[3] = new item(false, '<A HREF="page/121.html">1.2.1 Требования к тематике ВКР</A>', 2) outline[4] = new item(false, '<A HREF="page/122.html">1.2.2 Объекты, рекомендуемые к разработке</A>', 2) outline[5] = new item(false, '<A HREF="page/123.html">1.2.3 Рекомендуемые тематические направления выпускных квалификационных работ</A>', 2) outline[6] = new item(false, '<A HREF="page/13.html">1.3 Задание на выпускную квалификационную работу</A>', 1) outline[7] = new item(false, '<A HREF="page/14.html">1.4 Структура и содержание пояснительной записки</A>', 1) outline[8] = new item(true, '1.5 Оформление пояснительной записки', 1) outline[9] = new item(false, '<A HREF="page/151.html">1.5.1 Нормативные документы по оформлению пояснительной записки</A>', 2) outline[10] = new item(false, '<A HREF="page/152.html">1.5.2 Общие требования по оформлению пояснительной записки</A>', 2) outline[11] = new item(false, '<A HREF="page/16.html">1.6 Руководитель выпускной квалификационной работы и его обязанности</A>', 1) outline[12] = new item(false, '<A HREF="page/17.html">1.7 Рецензент выпускной квалификационной работы и его обязанности</A>', 1) outline[13] = new item(true, '1.8 Защита выпускной квалификационной работы (дипломного проекта или работы)', 1) outline[14] = new item(false, '<A HREF="page/181.html">1.8.1 Порядок защиты выпускной работы</A>', 2) outline[15] = new item(false, '<A HREF="page/182.html">1.8.2 Рекомендации по выступлению защищающегося</A>', 2) outline[16] = new item(false, '<A HREF="page/183.html">1.8.3 Демонстрация результатов проектирования</A>', 2)
outline[17] = new item(true, '2. Государственный экзамен', 0) outline[18] = new item(false, '<A HREF="page/21.html">2.1 Общие положения</A>', 1) outline[19] = new item(true, '2.2 Программа итогового междисциплинарного экзамена', 1) outline[20] = new item(false, '<A HREF="page/221.html">2.2.1 Перечень специальных дисциплин</A>', 2) outline[21] = new item(false, '<A HREF="page/222.html">2.2.2 Дисциплина «Конструкторско-технологическое обеспечение производства ЭВМ»</A>', 2) outline[22] = new item(false, '<A HREF="page/223.html">2.2.3 Дисциплина «Интерфейсы периферийных устройств»</A>', 2) outline[23] = new item(false, '<A HREF="page/224.html">2.2.4 Дисциплина «Микропроцессорные системы»</A>', 2) outline[24] = new item(false, '<A HREF="page/225.html">2.2.5 Дисциплина «Технология программирования»</A>', 2) outline[25] = new item(false, '<A HREF="page/23.html">2.3 Содержание экзаменационных билетов</A>', 1) outline[26] = new item(false, '<A HREF="page/24.html">2.4 Порядок проведения государственного междисциплинарного экзамена</A>', 1)
// determine current state of each item and assign to state properties setStates()
// set image for each item (only items with true state) setImages() }
function setStates() { // assign current cookie to local variable var storedValue = getCookie("outline") // if desired cookie not found (null) if (!storedValue) { // set states to default if no cookie found for (var i = 0; i < outline.length; ++i) { // only topmost level is visible by default if (outline[i].depth == 0) outline[i].state = true else outline[i].state = false } } else { // extract current states from cookie (0 => false, 1 => true) for (var i = 0; i < outline.length; ++i) { if (storedValue.charAt(i) == '1') outline[i].state = true else outline[i].state = false } } }
function setImages() { // loop through all elements of the outline "array" (object) for (var i = 0; i < outline.length; ++i) { if (outline[i].state) if (outline[i].parent) // outline[i] is a parent if (outline[i + 1].state) // outline[i] is exploded outline[i].pic = '<A HREF="javascript:toggle(' + i + ')"><IMG SRC="exploded.gif" BORDER=0></A>' else // outline[i] is collapsed outline[i].pic = '<A HREF="javascript:toggle(' + i + ')"><IMG SRC="collapsd.gif" BORDER=0></A>' else // outline[i] is only a child (not a parent) outline[i].pic = '<IMG SRC="child.gif" BORDER=0>' } }
// change from expanded to collapsed and vice versa function toggle(num) { // loop starts at item following argument // terminate loop when: // a) last element of outline "array" reached // b) current item (outline[i]) is not deeper than toggled item (outline[num]) for (var i = num + 1; i < outline.length && outline[i].depth >= outline[num].depth + 1; ++i) { // if current item (outline[i]) is a direct child of outline[num] if (outline[i].depth == outline[num].depth + 1) outline[i].state = !outline[i].state // toggle state }
// store new states in cookie setStorage()
// reload page history.go(0) }
function setStorage() { // initialize local variable to empty string var text = ""
// loop through all properties of outline "array" for (var i = 0; i < outline.length; ++i) { // use "1" character to represent true state, and "0" for false state text += (outline[i].state) ? "1" : "0" }
// create cookie named "outline" with "binary" string setCookie("outline", text) }
// update database makeDatabase()
// --> </SCRIPT> </HEAD> <BODY> <script LANGUAGE="JavaScript"> <!--
// use <PRE> to enable indentation via spaces document.write('<PRE><H3>')
// loop through elements of outline "array" for (var i = 0; i < outline.length; ++i) { // if current item's state is true if (outline[i].state) { // place three spaces for each nesting (depth * 3 spaces) for (var j = 0; j < outline[i].depth * 3; ++j) { document.write(' ') }
// follow indentation with picture, another space, text, and new line document.write(outline[i].pic, ' ', outline[i].text, '<BR>') } else { // current item's state is false (skip all its children) var previous = i for (var k = i + 1; k < outline.length && outline[k].depth >= outline[previous].depth; ++k) { ++i } } }
// end <PRE> to return to normal formatting document.write('</H3></PRE>')
// --> </SCRIPT> </BODY> </HTML>
|
|