Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

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.

HTML - Button Href - Variabel

Empfohlene Antworten

Hallo,

Wollte den onclick event beim Button dynamisch gestalten.

Leider funktioniert das nicht.

Findet einer den Grund?

 
<form name="myform" action="Startbildschirm.thml" method="post" />
Url: <input type="text" name="url" /><br />
<input type="button" value="GO TO" onclick="href=document.forms.myform.url.value">
</form>
[/PHP]

Gruß


<form name="myform" action="goto.php" method="post" />
Url: <input type="text" name="url" /><br />
<input type="submit" value="GO TO">
</form>
[/php]

die weiterleitung müsstest du in dem script machen das du als action des forms definiert hast.

Eine andere Möglichkeit ist auch die Weiterleitung per JavaScript zu realisieren, das ist allerdings die unschönere

Hab mir mal erlaubt den Code noch zu ergänzen:


<?php
if (!empty($_POST['url'])) {
header('location: '.$_POST['url']);
}
?>
<form action="<?=$_SERVER['PHP_SELF']?>" method="post" />
Url: <input type="text" name="url" /> <input type="submit" value="Gehe zu">
</form>
[/PHP]

Danke, aber dies setzt voraus, das PHP auf dem lokalen Rechner installiert ist und gleichzeitig noch ein Webserver läuft. Nun, es handelt sich hier um eine ME Maschine. Das HTML - Dokument soll als Desktop angezeigt werden (schnelle Suiche in Google und Leo). Hier mal den Code, den ich bis jetzt fertig habe.


------------------- Start.html --------------
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Startbildschirm</title>
</head>
<frameset rows="10%,90%" frameborder="0" framespacing="0" border="0">
<frame src="suche.html" name="suche" scrolling="no">
<frame src="daten.html" name="Daten" scrolling="no">
<noframes>
Ihr Browser kann diese Seite leider nicht anzeigen!
</noframes>
</body>
</html>

------------------- Suche.html --------------
</head>
<body text="#000000" bgcolor="#3A6EA5" link="#FF0000" alink="#FF0000" vlink="#FF0000">

<form action="daten.html" target="Daten" method="POST" name="myform" >
<select name="auswahl" size="1" >
<option value="http://www.google.de/search?q=">Google</option>
<option value="http://dict.leo.org/?search=">Dict.Leo.org</option>
</select>

<input type="Text" name="suchtext" value="" size="60" maxlength="" >
</input>

<input type="button" name="Verweis" value="Suchen" onClick="parent.frames['Daten'].document.location.href=document.forms.myform.auswahl.value + document.forms.myform.suchtext.value" >
</input>

</form>
</body>
</html>

------------------- Daten.html --------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Daten anzeigen</title>
</head>
<body text="#000000" bgcolor="#3A6EA5" link="#FF0000" alink="#FF0000" vlink="#FF0000">
</body>
</html>
[/PHP]

Nun, das ganze funktioniert auch. Nur leider nur 1x. Beim 2x kommt leider die Fehlermeldung "Zugriff verweigert" ? Hab ich was übersehen?

Gruß

warum verwendest du nicht einfach den Mozilla FireFox und dessen SearchPlugins?

Das ist nicht die Lösung zu meinem Problem.

Des der Firefox das bietet ist mir klar. Es gibt auch zig Erweiterungen für den IE. Ich hätte es aber gerne so. Ist bei der Arbeit eine Erleichterung

Gruß

Hi!

Ich hab mich dem Mal angenommen, bei mir funktionierts jetzt einwandfrei, allerdings nur in Browsern die den HTML-Standard beherrschen, sprich nicht in IE*.

index.htm


<?xml version="1.0"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"> 

<html>

	<head>

		<title>Startbildschirm</title>

	</head>

	<frameset rows="10%,90%">

	  <frame src="suche.htm" name="suche" scrolling="no" />

	  <frame src="daten.htm" name="Daten" scrolling="no" />

	</frameset>

</html>

suche.htm

<?xml version="1.0"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>

	<head>

		<title>Suche</title>

		<style type="text/css">

			body {

				background-color: #3a6ea5;

			}

			a {

				color: #f00;

			}

		</style>

	</head>

	<body>

		<form action="daten.htm" target="Daten" method="post">

		  <p>

		  	<select name="auswahl" id="auswahl" size="1" >

		    	<option value="http://www.google.de/search?q=">Google</option>

		    	<option value="http://dict.leo.org/?search=">Dict.Leo.org</option>

		  	</select> 

		  	<input type="text" name="suchtext" id="suchtext" value="" size="60" />

			  <input type="button" name="Verweis" value="Suchen" onclick="parent.frames['Daten'].window.location.href = document.getElementById('auswahl').value + document.getElementById('suchtext').value" />

			</p>

		</form>

	</body>

</html>

daten.htm

<?xml version="1.0"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>

	<head>

		<title>Daten anzeigen</title>

		<style type="text/css">

			body {

				background-color: #3a6ea5;

			}

		</style>

	</head>

	<body>

		<p>Bitte führe Sie die geünschte Suche durch</p>

	</body>

</html> 

Vielleicht kann ja mal einer testen warum der IE da muckt.

Gruß, Tobias

Wens interessiert: ich habs hinbekommen


<body text="#000000" bgcolor="#3A6EA5" link="#FF0000" alink="#FF0000" vlink="#FF0000">

<form action="daten.html" target="Daten" method="post" name="myform" >
<p align="center">
<select name="auswahl" size="1" onChange="parent.frames['Daten'].location.href=document.forms.myform.auswahl.value + document.forms.myform.suchtext.value" />
<!-- "parent.frames['Daten'].document.location.href=document.forms.myform.auswahl.value + document.forms.myform.suchtext.value">
-->
<option value="-"></option>
<option value="http://www.google.de/search?q=">Google</option>
<option value="http://dict.leo.org/?search=">Dict.Leo.org</option>
</select>

<input type="Text" name="suchtext" value="" size="60" maxlength="" >
</input>
</p>
<!--self.location.--->

<!--
"self.location.href=document.forms.myform.auswahl.value" + "document.forms.myform.suchtext.value"
document.forms.myform.suchtext.value
-->

</form>

</body>
</html>
[/PHP]

Der fehlerteufel lag in folgender falscher Anweisung:

parent.frames['Daten'].document.location.href=

korrekt ist:

parent.frames['Daten'].location.href=

Gruß

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

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.