我的网页首页有2个网址:
https://test/demo1/
或https://test/demo1/home
在主页中,我链接到其他页面:
<a href="carts" >Link 1</a>
如果我运行主页是:https://test/demo1/
链接打开是https://test/carts
如果我运行主页是:https://test/demo1/home
链接打开是https://test/demo1/carts
如何设置标记href
的相对a
,以便始终打开链接https://test/demo1/carts
?
答案 0 :(得分:2)
您可以调用函数添加attr或使用super()
更新href
public function question(Request $request)
{
static $startscore = 0;
$getidvalue = Input::get('getid');
$getanswervalue = Input::get('getanswer');
$dbscore = DB::table('5question')->select('question_id', 'correct_answer', 'question_marks')->where('question_id', '=', $getidvalue)->get();
foreach($dbscore as $value) {
if ($getanswervalue == ($value->correct_answer)) {
$getscore = $startscore + $value->question_marks;
}
elseif ($getanswervalue == null) {
$emptyvalue = - 1;
$getscore = $startscore + $emptyvalue;
}
else {
$novalue = 0;
$getscore = $startscore + $novalue;
}
}
echo "$getscore";
Session::push('getscoresession', $getscore);
$getsession = ['qid' => $getidvalue, 'answer' => $getanswervalue];
Session::push('answer', $getsession);
// return response()->json(['qid'=>$getidvalue,'answer'=>$getanswervalue]);
$score = array_sum(Session::get("getscoresession"));
// return view('submitquestion',compact('score'));
return view('submitquestion', ['score' => $score]);
}
jQuery
答案 1 :(得分:0)
解决此问题的一种简单方法是让您不希望重定向到正常网址的网址。添加以下内容,更改我想要的位置:
<meta http-equiv="refresh" content="3; url="file.html" />
^^^^^^^^^
这是一个常用元素,我个人在我的网站上经常使用它。 只要问一下有什么不清楚。但在此之前,请看这里:
http-equiv
:这实际上表示此元素会重定向页面。
content
:重定向(3
)和要重定向到的页面(file.html
)之前的秒数